﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports BusinessRule.IBusiness
Imports DatabaseAccess.IDAL
Imports System.Data
Imports BusinessRule.Common
Imports DatabaseAccess.DALFactory
Imports External.APICalling
Imports BusinessRule.DTO

Public Class uMESSynergicBusinessTest
    Implements uMESSynergicIBusinessTest
    Private dal As IOracleDAL = uMESDalContext.instance.GetDalObject()

    ''' <summary>
    ''' 获取已经保存的外协工序确认信息
    ''' </summary>
    ''' <returns></returns>
    Public Function GetSynergicSpecValidateInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicSpecValidateInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strProductName, strSpecName, strFactoryName As String
            strContainerName = ""
            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = QueryCondition("QueryContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If
            strSQL = "SELECT Container.Containername, Productbase.Productname, Employee.Fullname, SynergicSpecValidate.Submitdate, " & _
                "       DECODE(SynergicSpecValidate.AuditingDispose, 1,'同意',2,'不同意') AS AuditingDispose, AuditingEmployee.Fullname AS AuditingName, " & _
                "       SynergicSpecValidate.Auditingdate, SynergicSpecValidate.Auditingnotes, SynergicSpecValidate.Synergicspecvalidatename " & _
                "FROM SynergicSpecValidate   " & _
                "INNER JOIN Container ON Container.Containerid = SynergicSpecValidate.Containerid " & _
                "INNER JOIN Product ON Container.Productid = Product.Productid " & _
                "INNER JOIN Productbase ON Productbase.Productbaseid = Product.Productbaseid " & _
                "INNER JOIN Employee ON Employee.Employeeid = SynergicSpecValidate.Submitemployeeid " & _
                "LEFT OUTER JOIN Employee AuditingEmployee ON AuditingEmployee.Employeeid = SynergicSpecValidate.Auditingemployeeid " & _
                "INNER JOIN Currentstatus ON Container.Currentstatusid = Currentstatus.Currentstatusid " & _
                "LEFT OUTER JOIN Factory ON Factory.Factoryid = Currentstatus.Factoryid " & _
                "WHERE Container.Status = 1 AND Container.Qty > 0 AND SynergicSpecValidate.Status =1 AND SynergicSpecValidate.AuditingDispose <> 1 "

            If strContainerName <> "" Then
                strSQL = strSQL & "   AND Container.ContainerName = '" & strContainerName & "' "
            End If
            If strProductName <> "" Then
                strSQL = strSQL & "   AND Productbase.Productname LIKE '%" & strProductName & "%' "
            End If
            If strFactoryName <> "" Then
                strSQL = strSQL & "   AND Factory.Factoryname ='" & strFactoryName & "' "
            End If
            strSQL = strSQL & "ORDER BY Container.Containername, SynergicSpecValidate.Submitdate "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult

            oResult = dal.RunProcedureForPage(paraPage)

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

#Region "获取审批后的外协申请单列表"

    Private Function GetSynergicSpecValidateContainerList(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicSpecValidateContainerList
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strProductName, strSpecName, strFactoryName, strWorkCenterName, strSContainerName As String
            Dim commBusiness As uMESCommonBusiness = New uMESCommonBusiness()

            strContainerName = ""
            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = commBusiness.ReplaceContainerName(QueryCondition("QueryContainerName").ToString())
            End If
            strSContainerName = ""
            If QueryCondition.Keys.Contains("SearchContainerName") = True Then
                strSContainerName = QueryCondition("SearchContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If
            strWorkCenterName = ""
            If QueryCondition.Keys.Contains("WorkCenterName") = True Then
                strWorkCenterName = QueryCondition("WorkCenterName").ToString()
            End If

            strSQL = "select t.containerid,e1.employeename,e1.fullname,e2.employeename as auitemp,e2.fullname as quitfullname,t.synergicspecvalidateid,t.synergicspecvalidatename,t.submitdate," & vbCrLf & _
                     "t.auditingdate,t.submitemployeeid,t.auditingemployeeid,t.auditingdispose,c.containername,c.qty,pb.productname,p.description,p.productrevision,wc.workcentername," & vbCrLf & _
                     "t.workflowid,wb.workflowname,w.workflowrevision,sy.synergicinfoid,sy.synergicinfoname,cu.workflowstepid,cu.specid from SynergicSpecValidate  t " & vbCrLf & _
                     "left join container c on c.containerid=t.containerid " & vbCrLf & _
                     "LEFT JOIN currentstatus cu ON cu.currentstatusid=c.currentstatusid " & vbCrLf & _
                     "left join employee e1 on e1.employeeid=t.submitemployeeid " & vbCrLf & _
                     "left join employee e2 on e2.employeeid=t.auditingemployeeid " & vbCrLf & _
                     "left join product p on p.productid=c.productid " & vbCrLf & _
                     "left join productbase pb on pb.productbaseid=p.productbaseid " & vbCrLf & _
                     "left join workcenter wc on wc.workcenterid=c.workcenterid " & vbCrLf & _
                     "left join workflow w on w.workflowid=t.workflowid " & vbCrLf & _
                     "left join workflowbase wb on wb.workflowbaseid=w.workflowbaseid " & vbCrLf & _
                     "left join synergicinfo sy on sy.description=t.synergicspecvalidatename " & vbCrLf & _
                     "where t.auditingdispose=1 and nvl(sy.returnqty,0)=0 AND  c.Parentcontainerid IS NULL AND c.Status = 1 AND c.Containerid <> c.Containername "

            If strContainerName <> "" Then
                strSQL = strSQL & "   and c.ContainerName = '" & strContainerName & "' "
            Else
                If strSContainerName.Trim() <> "" Then
                    strSQL = strSQL & " and c.ContainerName like '%" & strSContainerName & "%'" & vbCrLf
                End If
            End If
            If strProductName <> "" Then
                strSQL = strSQL & "   and pb.Productname LIKE '%" & strProductName & "%' "
            End If

            If strWorkCenterName <> "" Then
                strSQL += " and wc.workcentername = '" & strWorkCenterName & "'" & vbCrLf
            End If

            If QueryCondition.Keys.Contains("StartDate") = True Then
                strSQL += "AND t.Submitdate >= TO_DATE('" & QueryCondition("StartDate").ToString & "','yyyy-MM-dd') " & vbCrLf
            End If
            If QueryCondition.Keys.Contains("EndDate") = True Then
                strSQL += "AND t.Submitdate <= TO_DATE('" & QueryCondition("EndDate").ToString & "','yyyy-MM-dd') " & vbCrLf
            End If

            If QueryCondition.Keys.Contains("state") = True Then
                If QueryCondition("state").Trim() = "已转出" Then
                    strSQL += "AND sy.SynergicInfoName IS NOT NULL" & vbCrLf
                ElseIf QueryCondition("state").Trim() = "未转出" Then
                    strSQL += "AND sy.SynergicInfoName IS  NULL" & vbCrLf
                End If
            End If


            strSQL = strSQL & " ORDER BY c.Containername "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult

            oResult = dal.RunProcedureForPage(paraPage)
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    Public Function GetSynergicSpecValidateDetail(ByVal strVaildateID As String) As DataTable Implements uMESSynergicIBusinessTest.GetSynergicSpecValidateDetail
        'Dim strVaildateID As String = ""

        'If QueryCondition.Keys.Contains("SynergicspecvalidateID") = True Then
        '    strVaildateID = QueryCondition("SynergicspecvalidateID").ToString()
        'End If

        Dim strSQL As String = "SELECT sy.specid,sy.specindex, sp.* FROM SynergicSpecValidateSynergicSp sp " & vbCrLf & _
                               "LEFT JOIN synergicspecinfo sy ON sy.synergicspecinfoid=sp.synergicspecinfoid " & vbCrLf & _
                               "WHERE sp.synergicspecvalidateid IN (" & strVaildateID & ")"
        Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)

        Return dtMain
    End Function
#End Region



    ''' <summary>
    ''' 根据批次获取待选择外协工序信息
    ''' </summary>
    ''' <returns></returns>
    Private Function GetContainerNeedSynergicInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetContainerNeedSynergicInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strContainerName As String = ""
            Dim strVaildateName As String = ""
            Dim commBusiness As uMESCommonBusiness = New uMESCommonBusiness()

            If QueryCondition.Keys.Contains("Synergicspecvalidatename") = True Then
                strVaildateName = QueryCondition("Synergicspecvalidatename").ToString()
            Else
                If QueryCondition.Keys.Contains("ContainerName") = True Then
                    strContainerName = commBusiness.ReplaceContainerName(QueryCondition("ContainerName").ToString())
                End If
            End If

            Dim strSQL As String = "select * from syncvaildata t "
            If strContainerName.Trim() <> "" Then
                strSQL = strSQL & "  where t.Containername='" & strContainerName & "'"
            Else
                strSQL = strSQL & "  where t.Synergicspecvalidatename='" & strVaildateName & "'"
            End If
            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
            dtMain = DataAdjust.FormatDataSetSpecNameByTwoColumName("SpecName", "CurSpecName", dtMain)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    Public Function GetValidateSpecInfo(ByVal QueryCondition As Dictionary(Of String, String)) As DataTable Implements uMESSynergicIBusinessTest.GetValidateSpecInfo
        Dim strContainerName As String = ""
        If QueryCondition.Keys.Contains("ContainerName") = True Then
            strContainerName = QueryCondition("ContainerName").ToString()
        End If
        Dim strSql As String = "select t.synergicspecvalidateid, t.synergicspecvalidatename, t.submitdate,t.submitemployeeid, t.containerid,t1.specid,cus.customername,sb.specname,c.containername," & vbCrLf & _
                               "e.employeename,e.fullname from synergicspecvalidate t " & vbCrLf & _
                               "inner join  SynergicSpecInfo t1 on t1.synergicspecvalidateid=t.synergicspecvalidateid " & vbCrLf & _
                               "left join Customer cus ON cus.Customerid =t1.customerid " & vbCrLf & _
                               "left join spec s on s.specid=t1.specid " & vbCrLf & _
                               "left join specbase sb on sb.specbaseid=s.specbaseid " & vbCrLf & _
                               "left join container c on c.containerid=t.containerid " & vbCrLf & _
                               "left join employee e on e.employeeid=t.submitemployeeid " & vbCrLf & _
                               "where  c.ContainerName = '" & strContainerName & "'"

        Dim dtMain As DataTable = dal.GetCheckTempInfo(strSql)
        dtMain = DataAdjust.FormatDataSetSpecNameByTwoColumName("SpecName", "CurSpecName", dtMain)
        Return dtMain
    End Function

    ''' <summary>
    ''' 根据批次获取待选择外协工序信息
    ''' </summary>
    ''' <returns></returns>
    Private Function GetSynergicSpecValidateDetailInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicSpecValidateDetailInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strSynergicSpecValidateName As String
            strSynergicSpecValidateName = ""
            Dim strBillNoList As String = ""

            If QueryCondition.Keys.Contains("SynergicSpecValidateName") = True Then
                strSynergicSpecValidateName = QueryCondition("SynergicSpecValidateName").ToString()
            End If

            If QueryCondition.Keys.Contains("SynergicSpecValidateNameList") = True Then
                strBillNoList = QueryCondition("SynergicSpecValidateNameList").ToString()
            End If

            strSQL = "SELECT DISTINCT Container.Containername, Productbase.Productname, Specbase.Specname AS CurSpecName,Spec.specid curspecid," & vbCrLf & _
                "            SynergicSpecbase.Specname, SynergicSpec.Specrevision,SynergicSpec.Specid, Workflowbase.WorkflowName, Workflow.Workflowrevision, " & vbCrLf & _
                "            SynergicSpecValidate.Synergicspecvalidatename, Customer.CustomerName,SynergicSpecInfo.Specindex,f.factoryname " & vbCrLf & _
                "FROM Container" & vbCrLf & _
                "INNER JOIN Currentstatus ON Container.Currentstatusid = Currentstatus.Currentstatusid" & vbCrLf & _
                "INNER JOIN Workflowstep ON Currentstatus.Workflowstepid = Workflowstep.Workflowstepid" & vbCrLf & _
                "INNER JOIN Workflowstep AllStep ON AllStep.Workflowid = Workflowstep.Workflowid" & vbCrLf & _
                "INNER JOIN Product ON Product.Productid = Container.Productid" & vbCrLf & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid" & vbCrLf & _
                "INNER JOIN SynergicSpecValidate ON SynergicSpecValidate.Containerid = Container.Containerid" & vbCrLf & _
                "INNER JOIN Spec ON Currentstatus.Specid = Spec.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "INNER JOIN Workflow ON SynergicSpecValidate.Workflowid = Workflow.Workflowid" & vbCrLf & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "LEFT OUTER JOIN SynergicSpecValidateSynergicSp ON SynergicSpecValidateSynergicSp.Synergicspecvalidateid = SynergicSpecValidate.Synergicspecvalidateid " & vbCrLf & _
                "LEFT OUTER JOIN SynergicSpecInfo ON SynergicSpecValidateSynergicSp.Synergicspecinfoid = SynergicSpecInfo.Synergicspecinfoid  " & vbCrLf & _
                "INNER JOIN Spec SynergicSpec ON SynergicSpecInfo.Specid = SynergicSpec.Specid" & vbCrLf & _
                "INNER JOIN Specbase SynergicSpecbase ON SynergicSpec.Specbaseid = SynergicSpecbase.Specbaseid" & vbCrLf & _
                "LEFT OUTER JOIN Customer ON Customer.Customerid = SynergicSpecInfo.Customerid" & vbCrLf & _
                "LEFT OUTER JOIN WorkCenterDispatching ON WorkCenterDispatching.Containerid = Container.Containerid" & vbCrLf & _
                "AND WorkCenterDispatching.Specid = SynergicSpec.Specid " & vbCrLf & _
                "LEFT JOIN factory f on f.factoryid=SynergicSpecInfo.Factoryid " & vbCrLf & _
                "WHERE WorkCenterDispatching.Workcenterdispatchingid IS NULL AND NVL(SynergicSpecValidate.Status,1) = 1  " & vbCrLf

            If strSynergicSpecValidateName <> "" Then
                strSQL = strSQL & "AND SynergicSpecValidate.SynergicSpecValidateName = '" & strSynergicSpecValidateName & "'" & vbCrLf
            End If

            If strBillNoList.Trim <> "" Then
                strSQL = strSQL & "AND SynergicSpecValidate.SynergicSpecValidateName in (" + strBillNoList + ")"
            End If
            If QueryCondition.Keys.Contains("currSpecStatus") Then
                strSQL = strSQL & " and Specbase.Specname =SynergicSpecbase.Specname AND Container.Containername='" + QueryCondition("currSpecStatus") + "'"
            End If
            strSQL = strSQL & "ORDER BY SynergicSpecInfo.Specindex" & vbCrLf

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
            dtMain = DataAdjust.FormatDataSetSpecNameByTwoColumName("SpecName", "CurSpecName", dtMain)

            For Each row As DataRow In dtMain.Rows
                If row.IsNull("CustomerName") = True Then
                    row("CustomerName") = row("factoryname")
                End If
            Next

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 获取已经保存的转工单信息
    ''' </summary>
    ''' <returns></returns>
    Private Function GetSynergicInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strProductName, strSpecName, strFactoryName As String
            strContainerName = ""
            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = QueryCondition("QueryContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If

            strSQL = "SELECT c.Containername, Productbase.Productname,Synergicinfo.Qty, Employee.Fullname, Synergicinfo.Submitdate,  " & vbCrLf & _
                "       Workflowbase.WorkflowName, Workflow.Workflowrevision, Specbase.Specname, Spec.Specrevision, " & vbCrLf & _
                "       Workflowstep.Sequence AS SpecIndex,Synergicinfo.Synergicinfoname,Product.Productrevision,Product.Description AS ProductDesc, " & vbCrLf & _
                "       (SELECT COUNT(*) FROM Synergicinfosynergicspecinfo sySpec WHERE sySpec.Synergicinfoid = Synergicinfo.Synergicinfoid) AS SpecCount" & vbCrLf & _
                "FROM Synergicinfo " & _
                "INNER JOIN Container c ON c.Containerid = Synergicinfo.Containerid  " & _
                "INNER JOIN Currentstatus ON c.Currentstatusid = Currentstatus.Currentstatusid " & _
                "LEFT OUTER JOIN Factory ON Factory.Factoryid = Currentstatus.Factoryid " & _
                "INNER JOIN Workflowstep ON Currentstatus.Workflowstepid = Workflowstep.Workflowstepid " & _
                "INNER JOIN Product ON c.Productid = Product.Productid  " & _
                "INNER JOIN Productbase ON Productbase.Productbaseid = Product.Productbaseid  " & _
                "INNER JOIN Employee ON Employee.Employeeid = Synergicinfo.Submitemployeeid   " & _
                "INNER JOIN Spec ON Synergicinfo.Specid = Spec.Specid " & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid " & _
                "INNER JOIN Workflow ON Synergicinfo.Workflowid = Workflow.Workflowid " & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid " & _
                "WHERE c.Status = 1 AND c.Qty > 0 AND c.Parentcontainerid IS NULL  " & _
                "AND Synergicinfo.Status =1 AND Synergicinfo.Returnspecid IS NULL "

            If strContainerName <> "" Then
                strSQL = strSQL & "   AND c.ContainerName = '" & strContainerName & "' "
            End If
            If QueryCondition.Keys.Contains("SecretLevel") = True Then
                strSQL += "AND (c.SecretLevel <= " & QueryCondition("SecretLevel").ToString & " OR c.SecretLevel IS NULL)" & vbCrLf
            End If
            If strProductName <> "" Then
                strSQL = strSQL & "   AND Productbase.Productname LIKE '%" & strProductName & "%' "
            End If
            If strFactoryName <> "" Then
                strSQL = strSQL & "   AND Factory.Factoryname ='" & strFactoryName & "' "
            End If

            strSQL = strSQL & "ORDER BY c.Containername, Synergicinfo.Submitdate "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult

            oResult = dal.RunProcedureForPage(paraPage)

            oResult.DBTable = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", oResult.DBTable).Copy

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 根据批次获取待选择外协工序信息
    ''' </summary>
    ''' <returns></returns>
    Private Function GetSynergicSpecInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicSpecInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strSpecIndex As String

            strContainerName = ""
            If QueryCondition.Keys.Contains("ContainerName") = True Then
                strContainerName = QueryCondition("ContainerName").ToString()
            End If

            strSpecIndex = ""
            If QueryCondition.Keys.Contains("SpecIndex") = True Then
                strSpecIndex = QueryCondition("SpecIndex").ToString()
            End If

            strSQL = "SELECT Container.Containername, Productbase.Productname, Specbase.Specname AS CurSpecName, Container.Qty,  NVL(CCurDispatch.CurDispatchNum, 0) AS CurDispatchNum, NVL(CSpecDispatch.DispatchNum,0) AS DispatchNum," & vbCrLf & _
                "            CSpec.Specname, CSpec.Specrevision, CSpec.Sequence, Workflowbase.WorkflowName, Workflow.Workflowrevision, Container.ContainerID, Workflowstep.Sequence AS CurrentSequence, " & vbCrLf & _
                "            CSpec.Sequence, CSynergicinfo.Synergicinfoname, Container.Status, CReturn.Specname AS ReturnSpecName, CReturn.Specrevision AS ReturnSpecRev, CValidate.CustomerName, NVL(CValidate.Status,0) as Status  " & vbCrLf & _
                "FROM Container" & vbCrLf & _
                "INNER JOIN Currentstatus ON Container.Currentstatusid = Currentstatus.Currentstatusid" & vbCrLf & _
                "INNER JOIN Workflowstep ON Currentstatus.Workflowstepid = Workflowstep.Workflowstepid" & vbCrLf & _
                "INNER JOIN Workflowstep AllStep ON AllStep.Workflowid = Workflowstep.Workflowid" & vbCrLf & _
                "AND AllStep.Sequence >= Workflowstep.Sequence" & vbCrLf & _
                "INNER JOIN Product ON Product.Productid = Container.Productid" & vbCrLf & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid" & vbCrLf & _
                "INNER JOIN Spec ON Currentstatus.Specid = Spec.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "INNER JOIN Workflow ON Workflowstep.Workflowid = Workflow.Workflowid" & vbCrLf & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "INNER JOIN Cdodefinition ON Cdodefinition.Cdodefid = Workflow.Cdotypeid " & _
                "INNER JOIN" & vbCrLf & _
                "(SELECT Workflowstep.Workflowstepid, Specbase.Specname, Spec.Specrevision, Workflowstep.Sequence, Spec.Specid" & vbCrLf & _
                "FROM Workflowstep" & vbCrLf & _
                "INNER JOIN Spec ON Workflowstep.Specid = Spec.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "WHERE Workflowstep.Specbaseid = '0000000000000000'" & vbCrLf '' AND (Spec.IsCooperation IS NULL OR Spec.Iscooperation = 2)" & vbCrLf

            If IsNumeric(strSpecIndex) = True Then
                strSQL = strSQL & "AND Workflowstep.Sequence >= " & CInt(strSpecIndex) & "" & vbCrLf
            End If

            strSQL = strSQL & "UNION ALL" & vbCrLf & _
                "SELECT Workflowstep.Workflowstepid, Specbase.Specname, Spec.Specrevision, Workflowstep.Sequence, Spec.Specid" & vbCrLf & _
                "FROM Workflowstep" & vbCrLf & _
                "INNER JOIN Specbase ON Workflowstep.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "INNER JOIN Spec ON Specbase.Revofrcdid = Spec.Specid" & vbCrLf & _
                "WHERE Workflowstep.Specid = '0000000000000000'" & vbCrLf '' AND (Spec.IsCooperation IS NULL OR Spec.Iscooperation = 2)" & vbCrLf

            If IsNumeric(strSpecIndex) = True Then
                strSQL = strSQL & "AND Workflowstep.Sequence >= " & CInt(strSpecIndex) & "" & vbCrLf
            End If

            strSQL = strSQL & ") CSpec" & vbCrLf & _
                "ON AllStep.Workflowstepid = CSpec.Workflowstepid" & vbCrLf & _
                "LEFT OUTER JOIN " & vbCrLf & _
                "(SELECT WorkCenterDispatching.Containerid, WorkCenterDispatching.Specid, COUNT(WorkCenterDispatching.Workcenterdispatchingid) AS DispatchNum" & vbCrLf & _
                "FROM WorkCenterDispatching" & vbCrLf & _
                "GROUP BY WorkCenterDispatching.Containerid, WorkCenterDispatching.Specid" & vbCrLf & _
                ") CSpecDispatch" & vbCrLf & _
                "ON CSpecDispatch.Containerid = Container.Containerid" & vbCrLf & _
                "AND CSpecDispatch.Specid = CSpec.Specid" & vbCrLf & _
                "LEFT OUTER JOIN " & vbCrLf & _
                "(SELECT WorkCenterDispatching.Containerid, WorkCenterDispatching.Specid, COUNT(WorkCenterDispatching.Workcenterdispatchingid) AS CurDispatchNum" & vbCrLf & _
                "FROM WorkCenterDispatching" & vbCrLf & _
                "GROUP BY WorkCenterDispatching.Containerid, WorkCenterDispatching.Specid" & vbCrLf & _
                ") CCurDispatch" & vbCrLf & _
                "ON CCurDispatch.Containerid = Container.Containerid" & vbCrLf & _
                "AND CCurDispatch.Specid = CSpec.Specid" & vbCrLf & _
                "LEFT OUTER JOIN " & vbCrLf & _
                "( " & vbCrLf & _
                "SELECT  Synergicinfo.Synergicinfoname,Synergicinfo.Containerid, Synergicinfo.Specid, Synergicinfo.Submitdate" & vbCrLf & _
                "FROM Synergicinfo" & vbCrLf & _
                "INNER JOIN" & vbCrLf & _
                "(" & vbCrLf & _
                "SELECT  Synergicinfo.Containerid, Max(Synergicinfo.Submitdate) AS Submitdate " & vbCrLf & _
                "FROM Synergicinfo " & vbCrLf & _
                "WHERE Synergicinfo.Status =1 AND Synergicinfo.Returnspecid IS NULL " & vbCrLf & _
                "GROUP BY Synergicinfo.Containerid" & vbCrLf & _
                ") CMax" & vbCrLf & _
                "ON CMax.Submitdate = Synergicinfo.Submitdate" & vbCrLf & _
                "AND  Synergicinfo.Containerid =  CMax.Containerid" & vbCrLf & _
                ") CSynergicinfo ON CSynergicinfo.Containerid = Container.Containerid " & vbCrLf & _
                "LEFT OUTER JOIN " & vbCrLf & _
                "(" & vbCrLf & _
                "SELECT Synergicinfo.Synergicinfoname, Specbase.Specname, Spec.Specrevision" & vbCrLf & _
                "FROM Synergicinfo" & vbCrLf & _
                "INNER JOIN SynergicInfoSynergicSpecInfo ON Synergicinfo.Synergicinfoid = SynergicInfoSynergicSpecInfo.Synergicinfoid" & vbCrLf & _
                "INNER JOIN Synergicspecinfo ON SynergicInfoSynergicSpecInfo.Synergicspecinfoid = Synergicspecinfo.Synergicspecinfoid" & vbCrLf & _
                "INNER JOIN Spec ON Synergicspecinfo.Specid = Spec.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "WHERE Synergicspecinfo.IsReturnSpec = 1" & vbCrLf & _
                ") CReturn" & vbCrLf & _
                "ON CSynergicinfo.Synergicinfoname = CReturn.Synergicinfoname  " & vbCrLf & _
                "LEFT OUTER JOIN " & vbCrLf & _
                "( " & vbCrLf & _
                "SELECT SynergicSpecValidate.Synergicspecvalidateid, SynergicSpecInfo.Specid, Customer.Customername, SynergicSpecValidate.Status,SynergicSpecValidate.Containerid " & vbCrLf & _
                "FROM SynergicSpecValidate " & vbCrLf & _
                "LEFT OUTER JOIN SynergicSpecValidateSynergicSp ON SynergicSpecValidateSynergicSp.Synergicspecvalidateid = SynergicSpecValidate.Synergicspecvalidateid " & vbCrLf & _
                "LEFT OUTER JOIN SynergicSpecInfo ON SynergicSpecValidateSynergicSp.Synergicspecinfoid = SynergicSpecInfo.Synergicspecinfoid  " & vbCrLf & _
                "LEFT OUTER JOIN Customer ON Customer.Customerid = SynergicSpecInfo.Customerid " & vbCrLf & _
                ") CValidate ON  CValidate.Containerid = Container.Containerid " & vbCrLf & _
                "AND CValidate.Specid = CSpec.Specid " & vbCrLf & _
                "WHERE Cdodefinition.Cdoname = 'MachineMfgWorkFlow' " & vbCrLf '"AND NVL(CSpecDispatch.DispatchNum,0) = 0  " & vbCrLf

            If strContainerName <> "" Then
                strSQL = strSQL & "AND Container.ContainerName = '" & strContainerName & "'" & vbCrLf
            End If

            strSQL = strSQL & "ORDER BY CSpec.Sequence" & vbCrLf

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
            dtMain = DataAdjust.FormatDataSetSpecNameByTwoColumName("SpecName", "CurSpecName", dtMain)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

#Region "得到外协申请单的工序信息"
    Public Function GetSynergicspecvalidateSpec(ByVal strSynergicspecvalidateID As String) As DataTable Implements uMESSynergicIBusinessTest.GetSynergicspecvalidateSpec
        Dim strSql As String = "select t.specid,t.specindex,t.synergictype,s.specrevision,sb.specname,cu.customername,f.factoryname  from SynergicSpecInfo t " & vbCrLf & _
                               "left join spec s on s.specid=t.specid " & vbCrLf & _
                               "left join specbase sb on sb.specbaseid=s.specbaseid " & vbCrLf & _
                               "left join customer cu on  cu.customerid=t.customerid " & vbCrLf & _
                               "left join factory f on f.factoryid=t.factoryid " & vbCrLf & _
                               " where t.synergicspecvalidateid='" & strSynergicspecvalidateID & "' order by t.specindex"

        Dim dtMain As DataTable = dal.GetCheckTempInfo(strSql)
        dtMain = DataAdjust.FormatDataSetSpecNameByTwoColumName("SpecName", "CurSpecName", dtMain)
        Return dtMain

    End Function
#End Region

    ''' <summary>
    ''' 获取当天最大流水号的外协工序确认单号
    ''' </summary>
    ''' <returns></returns>
    Private Function GetLastSynergicSpecValidate(ByVal QueryCondition As Dictionary(Of String, String)) As String Implements uMESSynergicIBusinessTest.GetLastSynergicSpecValidate
        Dim oResult As New uMESProcessResult
        Dim strSQL, strPrefix As String
        GetLastSynergicSpecValidate = ""
        strSQL = "SELECT SynergicSpecValidate.Synergicspecvalidatename" & vbCrLf & _
                "FROM SynergicSpecValidate" & vbCrLf & _
                "WHERE SynergicSpecValidate.Synergicspecvalidatename LIKE '" & Now.ToString("yyyyMMdd") & "%'" & vbCrLf & _
                "ORDER BY SynergicSpecValidate.Synergicspecvalidatename DESC" & vbCrLf

        Dim dtMain As DataTable = dal.GetQualityRecordInfoForProductNo(strSQL)
        strPrefix = Now.ToString("yyyyMMdd") & "_"
        If dtMain.Rows.Count > 0 Then
            Dim strLastScrapInfoName, strIndex As String
            Dim intIndex As Integer
            strLastScrapInfoName = dtMain.Rows(0).Item("Synergicspecvalidatename")
            intIndex = CInt(Trim(strLastScrapInfoName).Replace(strPrefix, ""))
            strIndex = Format(intIndex + 1, "00000")
            GetLastSynergicSpecValidate = strPrefix & strIndex
        Else
            GetLastSynergicSpecValidate = strPrefix & "00001"
        End If
    End Function

    ''' <summary>
    ''' 获取当天最大流水号的转工单号
    ''' </summary>
    ''' <returns></returns>
    Private Function GetLastSynergicInfo(ByVal QueryCondition As Dictionary(Of String, String)) As String Implements uMESSynergicIBusinessTest.GetLastSynergicInfo
        Dim oResult As New uMESProcessResult
        Dim strSQL, strPrefix As String
        GetLastSynergicInfo = ""
        strSQL = "SELECT SynergicInfo.SynergicInfoname" & vbCrLf & _
                "FROM SynergicInfo" & vbCrLf & _
                "WHERE SynergicInfo.SynergicInfoname LIKE '" & Now.ToString("yyyyMMdd") & "%'" & vbCrLf & _
                "ORDER BY SynergicInfo.SynergicInfoname DESC" & vbCrLf

        Dim dtMain As DataTable = dal.GetQualityRecordInfoForProductNo(strSQL)
        strPrefix = Now.ToString("yyyyMMdd") & "_"
        If dtMain.Rows.Count > 0 Then
            Dim strLastScrapInfoName, strIndex As String
            Dim intIndex As Integer
            strLastScrapInfoName = dtMain.Rows(0).Item("SynergicInfoname")
            intIndex = CInt(Trim(strLastScrapInfoName).Replace(strPrefix, ""))
            strIndex = Format(intIndex + 1, "00000")
            GetLastSynergicInfo = strPrefix & strIndex
        Else
            GetLastSynergicInfo = strPrefix & "00001"
        End If
    End Function

    ''' <summary>
    ''' 获取未审批的外协工序信息
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetSynergicSpecDisposeInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicSpecDisposeInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strProductName, strSContainerName, strWorkCenterName As String
            Dim dispatchBusiness As uMESDispatchBusiness = New uMESDispatchBusiness()
            Dim strContainerName As String = ""
            Dim strTogetherFlag As String = ""
            Dim commBusiness As uMESCommonBusiness = New uMESCommonBusiness()

            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = commBusiness.ReplaceContainerName(QueryCondition("QueryContainerName").ToString())

                Dim r As uMESProcessResult = dispatchBusiness.GetContainerInfo(strContainerName)
                If r.Result = True Then
                    Try
                        strTogetherFlag = r.DBTable.Rows(0)("TogetherFlag").ToString
                    Catch ex As Exception
                        strTogetherFlag = ""
                    End Try
                End If
            End If

            strSContainerName = ""
            If QueryCondition.Keys.Contains("SearchContainerName") = True Then
                strSContainerName = QueryCondition("SearchContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strWorkCenterName = ""
            If QueryCondition.Keys.Contains("WorkCenterName") = True Then
                strWorkCenterName = QueryCondition("WorkCenterName").ToString()
            End If
            strSQL = "SELECT  Container.Togetherflag, Container.Containername,Product.description, Productbase.Productname, Employee.Fullname, SynergicSpecValidate.Submitdate, " & _
                     "Workflowbase.WorkflowName,Workflow.Workflowrevision,Specbase.SpecName, AuditingEmployee.Fullname AS AuditingName, " & _
                     "SynergicSpecValidate.Auditingdate, SynergicSpecValidate.Auditingnotes, SynergicSpecValidate.Synergicspecvalidatename,e1.fullname as auditEmpName " & _
                     "FROM SynergicSpecValidate   " & _
                     "INNER JOIN Container ON Container.Containerid = SynergicSpecValidate.Containerid " & _
                     "INNER JOIN Currentstatus ON Container.Currentstatusid = Currentstatus.Currentstatusid " & _
                     "INNER JOIN Workflowstep ON Currentstatus.Workflowstepid = Workflowstep.Workflowstepid" & vbCrLf & _
                     "INNER JOIN Product ON Container.Productid = Product.Productid " & _
                     "LEFT JOIN WorkCenter wc ON wc.workcenterid = Container.workcenterid" & vbCrLf & _
                     "INNER JOIN Productbase ON Productbase.Productbaseid = Product.Productbaseid " & vbCrLf & _
                     "INNER JOIN Employee ON Employee.Employeeid = SynergicSpecValidate.Submitemployeeid " & vbCrLf & _
                "LEFT JOIN employee e1 on e1.employeeid=SynergicSpecValidate.Auditingemployeeid " & vbCrLf & _
                "INNER JOIN Spec ON Currentstatus.Specid = Spec.Specid" & vbCrLf & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & vbCrLf & _
                "INNER JOIN Workflow ON Workflowstep.Workflowid = Workflow.Workflowid" & vbCrLf & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "LEFT OUTER JOIN Employee AuditingEmployee ON AuditingEmployee.Employeeid = SynergicSpecValidate.Auditingemployeeid " & vbCrLf & _
                "WHERE Container.Status = 1 AND Container.Qty > 0 AND SynergicSpecValidate.Status =1  " 'AND SynergicSpecValidate.AuditingDispose =0


            If strTogetherFlag.Trim() <> "" Then
                strSQL = strSQL & " AND LOWER(Container.togetherflag) = '" & strTogetherFlag.ToLower & "'" & vbCrLf
            Else
                If strContainerName.Trim() <> "" Then
                    strSQL = strSQL & " AND Container.ContainerName = '" & strContainerName & "' "
                End If
            End If
            If strSContainerName.Trim() <> "" Then
                strSQL = strSQL & " AND Container.ContainerName like '%" & strSContainerName & "%'" & vbCrLf
            End If

            If strProductName <> "" Then
                strSQL = strSQL & " AND Productbase.Productname LIKE '%" & strProductName & "%' "
            End If
            If strWorkCenterName <> "" Then
                strSQL += " AND wc.workcentername = '" & strWorkCenterName & "'" & vbCrLf
            End If

            If QueryCondition.Keys.Contains("StartDate") = True Then
                strSQL += "AND SynergicSpecValidate.Submitdate >= TO_DATE('" & QueryCondition("StartDate").ToString & "','yyyy-MM-dd') " & vbCrLf
            End If
            If QueryCondition.Keys.Contains("EndDate") = True Then
                strSQL += "AND SynergicSpecValidate.Submitdate <= TO_DATE('" & QueryCondition("EndDate").ToString & "','yyyy-MM-dd') " & vbCrLf
            End If

            strSQL = strSQL & "ORDER BY Container.Containername, SynergicSpecValidate.Submitdate "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult

            oResult = dal.RunProcedureForPage(paraPage)

            oResult.DBTable = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", oResult.DBTable).Copy

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

#Region "获取已经保存的转工单信息"
    Public Function GetNeedAcceptSynergicInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetNeedAcceptSynergicInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strProductName, strFactoryName, strSContainerName, strWorkCenterName As String
            strContainerName = ""
            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = QueryCondition("QueryContainerName").ToString()
            End If
            strSContainerName = ""
            If QueryCondition.Keys.Contains("SearchContainerName") = True Then
                strSContainerName = QueryCondition("SearchContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If
            strWorkCenterName = ""
            If QueryCondition.Keys.Contains("WorkCenterName") = True Then
                strWorkCenterName = QueryCondition("WorkCenterName").ToString()
            End If
            strSQL = "SELECT c.Containername, pb.Productname,sy.Qty, e.Fullname, sy.Submitdate,p.productrevision,p.description AS productdesc," & vbCrLf & _
                    "   wfb.WorkflowName, wf.Workflowrevision, sb.Specname, s.Specrevision," & vbCrLf & _
                    "   (" & vbCrLf & _
                    "       SELECT ssi.synergictype FROM synergicspecinfo ssi" & vbCrLf & _
                    "       LEFT JOIN synergicinfosynergicspecinfo sissi on sissi.synergicspecinfoid = ssi.synergicspecinfoid" & vbCrLf & _
                    "       WHERE sissi.synergicinfoid = sy.synergicinfoid AND ROWNUM = 1" & vbCrLf & _
                    "   ) AS synergictype," & vbCrLf & _
                    "   wfs.Sequence AS SpecIndex,sy.Synergicinfoname, sy.Synergicinfoid,sy.description,wf.Workflowid, sy.Specid " & vbCrLf & _
                    "FROM Synergicinfo sy" & vbCrLf & _
                    "LEFT JOIN Container c ON c.Containerid = sy.Containerid" & vbCrLf & _
                    "LEFT JOIN Currentstatus cu ON c.Currentstatusid = cu.Currentstatusid" & vbCrLf & _
                    "LEFT JOIN Factory f ON f.Factoryid = cu.Factoryid" & vbCrLf & _
                    "LEFT JOIN Workflowstep wfs ON cu.Workflowstepid = wfs.Workflowstepid" & vbCrLf & _
                    "LEFT JOIN WorkCenter wc ON wc.workcenterid = c.workcenterid" & vbCrLf & _
                    "LEFT JOIN Product p ON c.Productid = p.Productid" & vbCrLf & _
                    "LEFT JOIN Productbase pb ON pb.Productbaseid = p.Productbaseid" & vbCrLf & _
                    "LEFT JOIN Employee e ON e.Employeeid = sy.Submitemployeeid" & vbCrLf & _
                    "LEFT JOIN Spec s ON sy.Specid = s.Specid" & vbCrLf & _
                    "LEFT JOIN Specbase sb ON s.Specbaseid = sb.Specbaseid" & vbCrLf & _
                    "LEFT JOIN Workflow wf ON sy.Workflowid = wf.Workflowid" & vbCrLf & _
                    "LEFT JOIN Workflowbase wfb ON wf.Workflowbaseid = wfb.Workflowbaseid" & vbCrLf & _
                    "WHERE c.Status = 1 AND c.Qty > 0 AND c.Parentcontainerid IS NULL  AND sy.Status =1 AND sy.Returnspecid IS NULL" & vbCrLf

            If strContainerName <> "" Then
                strSQL = strSQL & "   AND c.ContainerName = '" & strContainerName & "' "
            Else
                If strSContainerName.Trim() <> "" Then
                    strSQL = strSQL & "AND c.ContainerName like '%" & strSContainerName & "%'" & vbCrLf
                End If
                'If QueryCondition.Keys.Contains("SecretLevel") = True Then
                '    strSQL += "AND (c.secretlevel <= " & QueryCondition("SecretLevel").ToString & " OR c.secretlevel IS NULL)" & vbCrLf
                'End If
                If strProductName <> "" Then
                    strSQL = strSQL & "   AND pb.Productname LIKE '%" & strProductName & "%' "
                End If
                If strFactoryName <> "" Then
                    strSQL = strSQL & "   AND f.Factoryname ='" & strFactoryName & "' "
                End If
                If strWorkCenterName <> "" Then
                    strSQL += "AND wc.workcentername = '" & strWorkCenterName & "'" & vbCrLf
                End If
                If QueryCondition.Keys.Contains("StartDate") = True Then
                    strSQL += "AND sy.Submitdate >= TO_DATE('" & QueryCondition("StartDate").ToString & "','yyyy-MM-dd') " & vbCrLf
                End If
                If QueryCondition.Keys.Contains("EndDate") = True Then
                    strSQL += "AND sy.Submitdate <= TO_DATE('" & QueryCondition("EndDate").ToString & "','yyyy-MM-dd') " & vbCrLf
                End If
            End If

            strSQL = strSQL & "ORDER BY c.Containername "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult
            Dim dtMain As New DataTable
            result = dal.RunProcedureForPage(paraPage)

            dtMain = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", result.DBTable).Copy

            Dim strSynergicinfoID As String = ""
            If dtMain.Rows.Count > 0 Then
                For i = 0 To dtMain.Rows.Count - 1
                    If dtMain.Rows(i).IsNull("Synergicinfoid") = False Then
                        strSynergicinfoID = strSynergicinfoID & dtMain.Rows(i).Item("Synergicinfoid") & "','"
                    End If
                Next

            End If

            If strSynergicinfoID.Length > 0 Then
                strSynergicinfoID = strSynergicinfoID.Substring(0, strSynergicinfoID.Length - 3)
            End If

            strSQL = "SELECT  Synergicinfo.Synergicinfoname,Synergicinfo.Synergicinfoid, Specbase.Specname, Spec.Specrevision, Factory.Factoryname, Customer.Customername," & vbCrLf & _
                "       Synergicspecinfo.Specindex, Synergicspecinfo.Synergictype, Synergicspecinfo.Isreturnspec" & vbCrLf & _
                "FROM Synergicinfo " & vbCrLf & _
                "INNER JOIN SynergicInfoSynergicSpecInfo ON Synergicinfo.Synergicinfoid = SynergicInfoSynergicSpecInfo.Synergicinfoid" & vbCrLf & _
                "INNER JOIN Synergicspecinfo ON SynergicInfoSynergicSpecInfo.Synergicspecinfoid = Synergicspecinfo.Synergicspecinfoid" & vbCrLf & _
                "LEFT OUTER JOIN Spec ON Synergicspecinfo.Specid = Spec.Specid" & vbCrLf & _
                "LEFT OUTER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "LEFT OUTER JOIN Factory ON Synergicspecinfo.Factoryid = Factory.Factoryid" & vbCrLf & _
                "LEFT OUTER JOIN Customer ON Customer.Customerid = Synergicspecinfo.Customerid" & vbCrLf & _
                "WHERE 1=1 " & vbCrLf & _
                "AND Synergicinfo.Synergicinfoid IN ('" & strSynergicinfoID & "') " & vbCrLf & _
                "ORDER BY Synergicspecinfo.Specindex"

            Dim dtDetail As DataTable = dal.GetCheckPointResult(strSQL)
            dtDetail = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", dtDetail).Copy

            Dim ds As New DataSet
            ds.Tables.Add(dtMain.Copy())
            ds.Tables(0).TableName = "dtMain"
            ds.Tables.Add(dtDetail.Copy())
            ds.Tables(1).TableName = "dtDetail"

            Dim parentColunms = New DataColumn(0) {ds.Tables(0).Columns("Synergicinfoid")}
            Dim childColunms = New DataColumn(0) {ds.Tables(1).Columns("Synergicinfoid")}
            ds.Relations.Add("rs0", parentColunms, childColunms)

            oResult.DBDataSet = ds
            oResult.Result = True

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function
#End Region

#Region "获取已经外协车间需要确认和已经确认的转工单信息"
    Private Function GetNeedReturnSynergicInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetNeedReturnSynergicInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strContainerName, strProductName, strFactoryName, strSContainerName, strWorkCenterName As String
            Dim commBusiness As uMESCommonBusiness = New uMESCommonBusiness()
            strContainerName = ""
            If QueryCondition.Keys.Contains("QueryContainerName") = True Then
                strContainerName = commBusiness.ReplaceContainerName(QueryCondition("QueryContainerName").ToString())
            End If
            strSContainerName = ""
            If QueryCondition.Keys.Contains("SearchContainerName") = True Then
                strSContainerName = QueryCondition("SearchContainerName").ToString()
            End If
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If
            strWorkCenterName = ""
            If QueryCondition.Keys.Contains("WorkCenterName") = True Then
                strWorkCenterName = QueryCondition("WorkCenterName").ToString()
            End If
            strSQL = "SELECT c.Containername, pb.Productname,sy.Qty, e.Fullname, sy.Submitdate,sy.plandate,p.productrevision,p.description AS productdesc," & vbCrLf & _
                    "   wfb.WorkflowName, wf.Workflowrevision, sb.Specname, s.Specrevision," & vbCrLf & _
                    "   (" & vbCrLf & _
                    "       SELECT ssi.synergictype FROM synergicspecinfo ssi" & vbCrLf & _
                    "       LEFT JOIN synergicinfosynergicspecinfo sissi on sissi.synergicspecinfoid = ssi.synergicspecinfoid" & vbCrLf & _
                    "       WHERE sissi.synergicinfoid = sy.synergicinfoid AND ROWNUM = 1" & vbCrLf & _
                    "   ) AS synergictype," & vbCrLf & _
                    "   wfs.Sequence AS SpecIndex,sy.Synergicinfoname, sy.Synergicinfoid,sy.description,wf.Workflowid, sy.Specid " & vbCrLf & _
                    "FROM Synergicinfo sy" & vbCrLf & _
                    "LEFT JOIN Container c ON c.Containerid = sy.Containerid" & vbCrLf & _
                    "LEFT JOIN Currentstatus cu ON c.Currentstatusid = cu.Currentstatusid" & vbCrLf & _
                    "LEFT JOIN Factory f ON f.Factoryid = cu.Factoryid" & vbCrLf & _
                    "LEFT JOIN Workflowstep wfs ON cu.Workflowstepid = wfs.Workflowstepid" & vbCrLf & _
                    "LEFT JOIN WorkCenter wc ON wc.workcenterid = c.workcenterid" & vbCrLf & _
                    "LEFT JOIN Product p ON c.Productid = p.Productid" & vbCrLf & _
                    "LEFT JOIN Productbase pb ON pb.Productbaseid = p.Productbaseid" & vbCrLf & _
                    "LEFT JOIN Employee e ON e.Employeeid = sy.Submitemployeeid" & vbCrLf & _
                    "LEFT JOIN Spec s ON sy.Specid = s.Specid" & vbCrLf & _
                    "LEFT JOIN Specbase sb ON s.Specbaseid = sb.Specbaseid" & vbCrLf & _
                    "LEFT JOIN Workflow wf ON sy.Workflowid = wf.Workflowid" & vbCrLf & _
                    "LEFT JOIN Workflowbase wfb ON wf.Workflowbaseid = wfb.Workflowbaseid" & vbCrLf & _
                    "WHERE c.Status = 1 AND c.Qty > 0 AND c.Parentcontainerid IS NULL  AND sy.Returnspecid IS NULL" & vbCrLf

            strSQL = strSQL & "  AND sy.Status = " & QueryCondition("state").Trim() & " "

            If strContainerName <> "" Then
                strSQL = strSQL & "   AND c.ContainerName = '" & strContainerName & "' "
            Else
                If strSContainerName.Trim() <> "" Then
                    strSQL = strSQL & "AND c.ContainerName like '%" & strSContainerName & "%'" & vbCrLf
                End If
                'If QueryCondition.Keys.Contains("SecretLevel") = True Then
                '    strSQL += "AND (c.secretlevel <= " & QueryCondition("SecretLevel").ToString & " OR c.secretlevel IS NULL)" & vbCrLf
                'End If
                If strProductName <> "" Then
                    strSQL = strSQL & "   AND pb.Productname LIKE '%" & strProductName & "%' "
                End If
                If strFactoryName <> "" Then
                    strSQL = strSQL & "   AND f.Factoryname ='" & strFactoryName & "' "
                End If
                If strWorkCenterName <> "" Then
                    strSQL += "AND wc.workcentername = '" & strWorkCenterName & "'" & vbCrLf
                End If
                If QueryCondition.Keys.Contains("StartDate") = True Then
                    strSQL += "AND sy.Submitdate >= TO_DATE('" & QueryCondition("StartDate").ToString & "','yyyy-MM-dd') " & vbCrLf
                End If
                If QueryCondition.Keys.Contains("EndDate") = True Then
                    strSQL += "AND sy.Submitdate <= TO_DATE('" & QueryCondition("EndDate").ToString & "','yyyy-MM-dd') " & vbCrLf
                End If
            End If

            strSQL = strSQL & "ORDER BY c.Containername "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult
            Dim dtMain As New DataTable
            result = dal.RunProcedureForPage(paraPage)

            dtMain = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", result.DBTable).Copy

            Dim strSynergicinfoID As String = ""
            If dtMain.Rows.Count > 0 Then
                For i = 0 To dtMain.Rows.Count - 1
                    If dtMain.Rows(i).IsNull("Synergicinfoid") = False Then
                        strSynergicinfoID = strSynergicinfoID & dtMain.Rows(i).Item("Synergicinfoid") & "','"
                    End If
                Next

            End If

            If strSynergicinfoID.Length > 0 Then
                strSynergicinfoID = strSynergicinfoID.Substring(0, strSynergicinfoID.Length - 3)
            End If

            strSQL = "SELECT  Synergicinfo.Synergicinfoname,Synergicinfo.Synergicinfoid, Specbase.Specname, Spec.Specrevision, Factory.Factoryname, Customer.Customername," & vbCrLf & _
                "       Synergicspecinfo.Specindex, Synergicspecinfo.Synergictype, Synergicspecinfo.Isreturnspec,Synergicspecinfo.Specid" & vbCrLf & _
                "FROM Synergicinfo " & vbCrLf & _
                "INNER JOIN SynergicInfoSynergicSpecInfo ON Synergicinfo.Synergicinfoid = SynergicInfoSynergicSpecInfo.Synergicinfoid" & vbCrLf & _
                "INNER JOIN Synergicspecinfo ON SynergicInfoSynergicSpecInfo.Synergicspecinfoid = Synergicspecinfo.Synergicspecinfoid" & vbCrLf & _
                "LEFT OUTER JOIN Spec ON Synergicspecinfo.Specid = Spec.Specid" & vbCrLf & _
                "LEFT OUTER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "LEFT OUTER JOIN Factory ON Synergicspecinfo.Factoryid = Factory.Factoryid" & vbCrLf & _
                "LEFT OUTER JOIN Customer ON Customer.Customerid = Synergicspecinfo.Customerid" & vbCrLf & _
                "WHERE 1=1 " & vbCrLf & _
                "AND Synergicinfo.Synergicinfoid IN ('" & strSynergicinfoID & "') " & vbCrLf & _
                "ORDER BY Synergicspecinfo.Specindex"

            Dim dtDetail As DataTable = dal.GetCheckPointResult(strSQL)
            dtDetail = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", dtDetail).Copy

            Dim ds As New DataSet
            ds.Tables.Add(dtMain.Copy())
            ds.Tables(0).TableName = "dtMain"
            ds.Tables.Add(dtDetail.Copy())
            ds.Tables(1).TableName = "dtDetail"

            Dim parentColunms = New DataColumn(0) {ds.Tables(0).Columns("Synergicinfoid")}
            Dim childColunms = New DataColumn(0) {ds.Tables(1).Columns("Synergicinfoid")}
            ds.Relations.Add("rs0", parentColunms, childColunms)

            oResult.DBDataSet = ds
            oResult.Result = True
            oResult.PageCount = result.PageCount
            oResult.RowCount = result.RowCount

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function
#End Region



    ''' <summary>
    ''' 创建外协工序确认信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">创建外协工序确认所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function CreateSynergicSpecValidate(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.CreateSynergicSpecValidate
        CreateSynergicSpecValidate = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicSpecValidateMaintDoc"
            strTxnName = "SynergicSpecValidateMaint"
            strEventName = "New"
            strSubentityListName = "SynergicSpecInfo"

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Name"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicSpecValidateName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.ContainerField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Container"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ContainerName
            dataEntity.ClientOtherValue = ""
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
            Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Workflow"
            dataEntity.ClientDataValue = strWorkflowName
            If strWorkflowRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strWorkflowRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strWorkflowRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingDispose"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingDispose
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oSynergicInfoDTO.SynergicSpecInfo

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecName").ToString
                        Dim strSpecRev As String = dtChildList.Rows(i).Item("SpecRev").ToString
                        If strSpecRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SynergicType"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SynergicType").ToString
                        m_Child.Add(stepEntity)

                        If dtChildList.Rows(i).Item("CustomerName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Customer"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecIndex"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecIndex").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.CreateModelHasSubentityList(strTxnDocName, strTxnName, strEventName, m_DataList, strSubentityListName, m_ChildList, strInfo)

            If success = True Then
                CreateSynergicSpecValidate = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 修改外协工序信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">修改外协工序信息所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function UpdateSynergicSpecValidate(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.UpdateSynergicSpecValidate
        UpdateSynergicSpecValidate = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicSpecValidateMaintDoc"
            strTxnName = "SynergicSpecValidateMaint"
            strEventName = "Load"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicSpecValidateName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSubentityListCount As Integer
            intSubentityListCount = oSynergicInfoDTO.SubentityListCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            If IsNothing(oSynergicInfoDTO.ContainerName) = False Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.ContainerField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Container"
                dataEntity.ClientDataValue = oSynergicInfoDTO.ContainerName
                dataEntity.ClientOtherValue = ""
                m_DataList.Add(dataEntity)
            End If

            If IsNothing(oSynergicInfoDTO.WorkflowName) = False Then
                dataEntity = New ClientAPIEntity
                Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
                Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

                dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Workflow"
                dataEntity.ClientDataValue = strWorkflowName
                If strWorkflowRev <> "" Then
                    dataEntity.ClientDataIsROR = False
                    dataEntity.ClientDataVersion = strWorkflowRev
                Else
                    dataEntity.ClientDataIsROR = True
                    dataEntity.ClientDataVersion = strWorkflowRev
                End If
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingDispose"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingDispose
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oSynergicInfoDTO.SynergicSpecInfo

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecName").ToString
                        Dim strSpecRev As String = dtChildList.Rows(i).Item("SpecRev").ToString
                        If strSpecRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SynergicType"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SynergicType").ToString
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecIndex"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecIndex").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelHasSubentityList(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                            strUpdateCDOType, m_DataList, strSubentityListName, m_ChildList, intSubentityListCount, strInfo)

            If success = True Then
                UpdateSynergicSpecValidate = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 审核外协工序信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">审核外协工序信息所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DisposeSynergicSpecValidate(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.DisposeSynergicSpecValidate
        DisposeSynergicSpecValidate = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicSpecValidateMaintDoc"
            strTxnName = "SynergicSpecValidateMaint"
            strEventName = "Load"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicSpecValidateName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSubentityListCount As Integer
            intSubentityListCount = oSynergicInfoDTO.SubentityListCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingDispose"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingDispose
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingNotes"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingNotes
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "AuditingDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.AuditingDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oSynergicInfoDTO.SynergicSpecInfo

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecName").ToString
                        Dim strSpecRev As String = dtChildList.Rows(i).Item("SpecRev").ToString
                        If strSpecRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SynergicType"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SynergicType").ToString
                        m_Child.Add(stepEntity)

                        If Convert.ToInt32(dtChildList.Rows(i).Item("SynergicType")) = 1 Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Factory"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)

                        Else
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Customer"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecIndex"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecIndex").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelHasSubentityList(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                            strUpdateCDOType, m_DataList, strSubentityListName, m_ChildList, intSubentityListCount, strInfo)

            If success = True Then
                DisposeSynergicSpecValidate = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 审核外协工序信息新
    ''' </summary>
    Public Function DisposeSynergicSpecValidateNew(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.DisposeSynergicSpecValidateNew
        DisposeSynergicSpecValidateNew = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim strSQL As String
            strSQL = "update synergicspecvalidate t set t.auditingnotes='" & oSynergicInfoDTO.AuditingNotes & "',t.auditingdate=To_date('" & oSynergicInfoDTO.AuditingDate & "','yyyy-mm-dd HH24:mi:ss')," & vbCrLf & _
                    "t.auditingdispose='" & oSynergicInfoDTO.AuditingDispose & "',t.auditingemployeeid=(SELECT e.employeeid FROM employee e WHERE e.employeename='" & oSynergicInfoDTO.AuditingEmployee & "')" & vbCrLf & _
                    "WHERE t.synergicspecvalidatename='" & oSynergicInfoDTO.SynergicSpecValidateName & "'" & vbCrLf
            dal.ExecuteSql(strSQL)

            Dim dt As DataTable = oSynergicInfoDTO.SynergicSpecInfo
            Dim Specid As String
            Dim CustomerName As String
            Dim SynergicType As String
            Dim SpecIndex As String
            For i As Integer = 0 To oSynergicInfoDTO.SubentityListCount - 1
                Specid = dt.Rows(i)("Specid")
                CustomerName = dt.Rows(i)("CustomerName")
                SynergicType = dt.Rows(i)("SynergicType")
                SpecIndex = dt.Rows(i)("SpecIndex")

                strSQL = String.Format("UPDATE synergicspecinfo t SET t.SynergicType='1', t.factoryid='{0}' " & vbCrLf & _
                                      "WHERE t.synergicspecvalidateid=(SELECT s.synergicspecvalidateid FROM synergicspecvalidate s WHERE s.synergicspecvalidatename='{1}')", dt.Rows(i)("factoryid").ToString().Trim(), oSynergicInfoDTO.SynergicSpecValidateName)

                dal.ExecuteSql(strSQL)

                'strSQL = "update synergicspecinfo t set t.customerid=(SELECT cus.customerid  FROM customer cus WHERE cus.customername='" & CustomerName & "')," & vbCrLf & _
                '         "t.Specid='" & Specid & "',t.SynergicType='" & SynergicType & "',t.SpecIndex='" & SpecIndex & "'," & vbCrLf &
                '         "t.factoryid=(SELECT ft.factoryid  FROM factory ft WHERE ft.factoryname='" & CustomerName & "')" & vbCrLf & _
                '         "WHERE t.synergicspecvalidateid=(SELECT s.synergicspecvalidateid FROM synergicspecvalidate s WHERE s.synergicspecvalidatename='" & oSynergicInfoDTO.SynergicSpecValidateName & "')" & vbCrLf

            Next

            DisposeSynergicSpecValidateNew = True
            result = True
            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function



    ''' <summary>
    ''' 删除外协工序信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">删除外协工序信息所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DeleteSynergicSpecValidate(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.DeleteSynergicSpecValidate
        DeleteSynergicSpecValidate = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicSpecValidateMaintDoc"
            strTxnName = "SynergicSpecValidateMaint"
            strEventName = "Delete"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicSpecValidateName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.DeleteModel(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, strUpdateCDOType, strInfo)

            If success = True Then
                DeleteSynergicSpecValidate = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 创建转工单信息
    ''' </summary>
    Public Function CreateSynergicInfo(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.CreateSynergicInfo
        CreateSynergicInfo = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicInfoMaintDoc"
            strTxnName = "SynergicInfoMaint"
            strEventName = "New"
            strSubentityListName = "SynergicSpecInfo"

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Name"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicSpecValidateName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Description"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Notes
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.ContainerField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Container"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ContainerName
            dataEntity.ClientOtherValue = ""
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
            Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Workflow"
            dataEntity.ClientDataValue = strWorkflowName
            If strWorkflowRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strWorkflowRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strWorkflowRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strSpecName As String = oSynergicInfoDTO.SpecName
            Dim strSpecRev As String = oSynergicInfoDTO.SpecRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Spec"
            dataEntity.ClientDataValue = strSpecName
            If strSpecRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strSpecRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strSpecRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Qty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Qty
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "FromFactory"
            dataEntity.ClientDataValue = oSynergicInfoDTO.FromFactoryName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ToFactory"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ToFactoryName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oSynergicInfoDTO.SynergicSpecInfo

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecName").ToString
                        Dim strSpecDetailRev As String = dtChildList.Rows(i).Item("SpecRev").ToString
                        If strSpecDetailRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SynergicType"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SynergicType").ToString
                        m_Child.Add(stepEntity)

                        If dtChildList.Rows(i).Item("CustomerName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Customer"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        If dtChildList.Rows(i).Item("FactoryName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Factory"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("FactoryName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecIndex"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecIndex").ToString
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "IsReturnSpec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("IsReturnSpec").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.CreateModelHasSubentityList(strTxnDocName, strTxnName, strEventName, m_DataList, strSubentityListName, m_ChildList, strInfo)


            If success = True Then
                CreateSynergicInfo = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 修改转工单信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">修改转工单所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function UpdateSynergicInfo(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.UpdateSynergicInfo
        UpdateSynergicInfo = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicInfoMaintDoc"
            strTxnName = "SynergicInfoMaint"
            strEventName = "Load"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicSpecValidateName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSubentityListCount As Integer
            intSubentityListCount = oSynergicInfoDTO.SubentityListCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            If IsNothing(oSynergicInfoDTO.ContainerName) = False Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.ContainerField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Container"
                dataEntity.ClientDataValue = oSynergicInfoDTO.ContainerName
                dataEntity.ClientOtherValue = ""
                m_DataList.Add(dataEntity)
            End If

            If IsNothing(oSynergicInfoDTO.WorkflowName) = False Then
                dataEntity = New ClientAPIEntity
                Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
                Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

                dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Workflow"
                dataEntity.ClientDataValue = strWorkflowName
                If strWorkflowRev <> "" Then
                    dataEntity.ClientDataIsROR = False
                    dataEntity.ClientDataVersion = strWorkflowRev
                Else
                    dataEntity.ClientDataIsROR = True
                    dataEntity.ClientDataVersion = strWorkflowRev
                End If
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            Dim strSpecName As String = oSynergicInfoDTO.SpecName
            Dim strSpecRev As String = oSynergicInfoDTO.SpecRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Spec"
            dataEntity.ClientDataValue = strSpecName
            If strSpecRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strSpecRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strSpecRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Qty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Qty
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "FromFactory"
            dataEntity.ClientDataValue = oSynergicInfoDTO.FromFactoryName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ToFactory"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ToFactoryName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oSynergicInfoDTO.SynergicSpecInfo

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecName").ToString
                        Dim strSpecDetailRev As String = dtChildList.Rows(i).Item("SpecRev").ToString
                        If strSpecDetailRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SynergicType"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SynergicType").ToString
                        m_Child.Add(stepEntity)

                        If dtChildList.Rows(i).Item("CustomerName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Customer"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        If dtChildList.Rows(i).Item("FactoryName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Factory"
                            stepEntity.ClientDataValue = dtChildList.Rows(i).Item("FactoryName").ToString
                            m_Child.Add(stepEntity)
                        End If

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecIndex"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("SpecIndex").ToString
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "IsReturnSpec"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("IsReturnSpec").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelHasSubentityList(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                            strUpdateCDOType, m_DataList, strSubentityListName, m_ChildList, intSubentityListCount, strInfo)

            If success = True Then
                UpdateSynergicInfo = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 删除转工单
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">删除转工单所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DeleteSynergicInfo(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.DeleteSynergicInfo
        DeleteSynergicInfo = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicInfoMaintDoc"
            strTxnName = "SynergicInfoMaint"
            strEventName = "Delete"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicSpecValidateName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.DeleteModel(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                            strUpdateCDOType, strInfo)

            If success = True Then
                DeleteSynergicInfo = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 转工单进行转工移回信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">转工单进行转工移回所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' 
    Public Function ReturnSynergicInfo(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.ReturnSynergicInfo
        ReturnSynergicInfo = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicInfoMaintDoc"
            strTxnName = "SynergicInfoMaint"
            strEventName = "Load"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicInfoName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSubentityListCount As Integer
            intSubentityListCount = oSynergicInfoDTO.SubentityListCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity = New ClientAPIEntity
            Dim strSpecName As String = oSynergicInfoDTO.SpecName
            Dim strSpecRev As String = oSynergicInfoDTO.SpecRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ReturnSpec"
            dataEntity.ClientDataValue = strSpecName
            If strSpecRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strSpecRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strSpecRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ReturnQty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ReturnQty
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ReturnNotes"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ReturnNotes
            m_DataList.Add(dataEntity)

            If IsNothing(oSynergicInfoDTO.ReturnDocUrl) = False Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "ReturnDocUrl"
                dataEntity.ClientDataValue = oSynergicInfoDTO.ReturnDocUrl
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ReturnEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ReturnEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "ReturnDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.ReturnDate
            m_DataList.Add(dataEntity)

            ''超差数
            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientDataName = "CCQty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.CCQty
            m_DataList.Add(dataEntity)

            ''质疑单号
            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientDataName = "QueryBillNo"
            dataEntity.ClientDataValue = oSynergicInfoDTO.QueryBillNo
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = "0"
            m_DataList.Add(dataEntity)

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelByStandard(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                             m_DataList, strInfo)

            If success = True Then
                Dim strUpdate As String = String.Format("update  SynergicSpecValidate t set t.status=0 where t.synergicspecvalidatename='{0}'", oSynergicInfoDTO.SynergicValidateName)
                dal.ExecuteQuery(strUpdate)
                ReturnSynergicInfo = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 转工单进行转工移回信息新
    ''' </summary>
    Public Function ReturnSynergicInfoNew(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.ReturnSynergicInfoNew
        ReturnSynergicInfoNew = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim strSQL As String
            strSQL = "update synergicinfo s set s.status='0', s.ccqty='" & oSynergicInfoDTO.CCQty & "',s.returndate=To_date('" & oSynergicInfoDTO.ReturnDate & "','yyyy-mm-dd HH24:mi:ss')," & vbCrLf & _
                    "s.returndocurl='" & oSynergicInfoDTO.ReturnDocUrl & "',s.returnemployeeid=(SELECT e.employeeid FROM employee e WHERE e.employeename='" & oSynergicInfoDTO.ReturnEmployee & "')," & vbCrLf & _
                    "s.returnnotes='" & oSynergicInfoDTO.ReturnNotes & "',s.returnqty='" & oSynergicInfoDTO.ReturnQty & "'," & vbCrLf & _
                    "s.returnspecid='" & oSynergicInfoDTO.SpecId & "',s.querybillno='" & oSynergicInfoDTO.QueryBillNo & "'" & vbCrLf & _
                    "WHERE s.SynergicInfoName='" & oSynergicInfoDTO.SynergicInfoName & "'" & vbCrLf
            dal.ExecuteSql(strSQL)
            Dim strUpdate As String = String.Format("update  SynergicSpecValidate t set t.status=0 where t.synergicspecvalidatename='{0}'", oSynergicInfoDTO.SynergicValidateName)
            dal.ExecuteSql(strUpdate)
            ReturnSynergicInfoNew = True
            result = True
            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

#Region "外协车间接收和确认登记"
    Public Function AcceptUpdateSynergicInfo(ByVal oSynergicInfoDTO As uMESSynergicInfoDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.AcceptUpdateSynergicInfo
        AcceptUpdateSynergicInfo = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName As String
            strTxnDocName = "SynergicInfoMaintDoc"
            strTxnName = "SynergicInfoMaint"
            strEventName = "Load"
            strSubentityListName = "SynergicSpecInfo"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicInfoName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSubentityListCount As Integer
            intSubentityListCount = oSynergicInfoDTO.SubentityListCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity
            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelByStandard(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                             m_DataList, strInfo)
            If success = True Then
                AcceptUpdateSynergicInfo = True
                result = True
            End If
            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function
#End Region



    ''' <summary>
    ''' 根据父批次获取子件号
    ''' </summary>
    ''' <returns></returns>
    Private Function GetChildContainerByParent(ByVal strContainerName As String) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetChildContainerByParent
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL As String

            strSQL = "select c.containername, c.status " & vbCrLf & _
                " from container c " & vbCrLf & _
                " left join container cc on c.parentcontainerid = cc.containerid  " & vbCrLf & _
                "where 1=1 and cc.status=1  and cc.containername<>cc.containerid " & vbCrLf
            If strContainerName <> "" Then
                strSQL = strSQL & "and cc.containername = '" & strContainerName & "'" & vbCrLf
            End If
            strSQL = strSQL & "order by c.containername" & vbCrLf

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
            dtMain.Columns.Add("childcontainername")
            For Each row As DataRow In dtMain.Rows
                dtMain.AcceptChanges()
                row("childcontainername") = row("containername").ToString().Replace(strContainerName & "-", "")
            Next

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 根据SPEC获取STEP
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetStepBySpecID(ByVal strSpecName As String, ByVal strSpecRev As String, ByVal strWorkflowID As String) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetStepBySpecID
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL As String

            strSQL = "select s.specid ,wfs.workflowstepname, specbase.specname " & vbCrLf & _
                " from specbase sb " & vbCrLf & _
                " inner join spec s on sb.specbaseid = s.specbaseid  " & vbCrLf & _
                " inner join specbase on specbase.specbaseid = sb.specbaseid " & vbCrLf & _
                " inner join ( " & vbCrLf & _
                " select (case when workflowstep.specid = '0000000000000000' then (select revofrcdid from specbase where specbaseid = workflowstep.specbaseid) else workflowstep.specid end ) as specid,workflowstep.workflowstepname,workflowstep.workflowid from workflowstep) wfs " & vbCrLf & _
                " on wfs.specid = s.specid " & vbCrLf & _
                " where 1=1 " & vbCrLf

            If strSpecName <> "" Then
                strSQL = strSQL & " and specbase.specname = '" & strSpecName & "' " & vbCrLf
            End If
            If strSpecRev <> "" Then
                strSQL = strSQL & " and s.specrevision = '" & strSpecRev & "'" & vbCrLf
            End If
            If strWorkflowID <> "" Then
                strSQL = strSQL & " and wfs.workflowid = '" & strWorkflowID & "' " & vbCrLf
            End If

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

#Region "修改批次数量"
    ''' <summary>
    ''' 修改批次数量
    ''' </summary>
    ''' <param name="oChangeQtyDTO">修改批次数量所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function ChangeQty(ByVal oChangeQtyDTO As uMESChangeQtyDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.ChangeQty 'ByVal Container As String, ByVal ChangeQtyType As String, ByVal Qty As String, ByVal ReasonCode As String) As Boolean
        ChangeQty = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oChangeQtyDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName As String
            strTxnDocName = "ChangeQtyDoc"
            strTxnName = "ChangeQty"

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity.ClientDataTypeEnum = DataTypeEnum.ContainerField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Container"
            dataEntity.ClientDataValue = oChangeQtyDTO.ContainerName
            dataEntity.ClientOtherValue = ""
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtChildList As DataTable = oChangeQtyDTO.ChangeQtyDetail

            If dtChildList IsNot Nothing Then
                If dtChildList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtChildList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                        stepEntity.ClientDataName = "Qty"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("Qty").ToString
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                        dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                        stepEntity.ClientDataName = "ReasonCode"
                        stepEntity.ClientDataValue = dtChildList.Rows(i).Item("ReasonCode").ToString
                        m_Child.Add(stepEntity)
                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)

            success = clientData.ContainerChangeQty(strTxnDocName, strTxnName, m_DataList, "ServiceDetails", m_ChildList, _
                                                    oChangeQtyDTO.ChangeQtyType, strInfo)

            If success = True Then
                ChangeQty = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function
#End Region

    ''' <summary>
    ''' 获取外协目录信息
    ''' </summary>
    ''' <returns></returns>
    Private Function GetSynergicDirectoryInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicDirectoryInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strProductName, strWorkflowName, strFactoryName As String
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strWorkflowName = ""
            If QueryCondition.Keys.Contains("WorkflowName") = True Then
                strWorkflowName = QueryCondition("WorkflowName").ToString()
            End If

            strFactoryName = ""
            If QueryCondition.Keys.Contains("FactoryName") = True Then
                strFactoryName = QueryCondition("FactoryName").ToString()
            End If
            strSQL = "SELECT Productbase.Productname,Workflowbase.Workflowname,  Factory.Factoryname,  Synergicdirectory.Qty, Product.Materialtrademark,  " & _
                "       Product.Materialspecification, SynergicValidateType.SynergicValidateTypeName, (Synergicdirectory.IsFirstSynergic || '') AS IsFirstSynergic, " & _
                "       (Synergicdirectory.Isimport || '') AS Isimport, Secretlevel.Secretlevelname, " & _
                "       Synergictype.Synergictypename, Employee.Fullname, Synergicdirectory.Submitdate, CSpec.SpecCount, CCustomer.CustomerCount, " & _
                "       Synergicdirectory.Synergicdirectoryname,  Product.Productrevision, Workflow.Workflowrevision " & _
                "FROM Synergicdirectory " & _
                "INNER JOIN Product ON Synergicdirectory.Productid = Product.Productid " & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid " & _
                "INNER JOIN Workflow ON Synergicdirectory.Workflowid = Workflow.Workflowid " & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid " & _
                "LEFT OUTER JOIN SynergicValidateType ON SynergicValidateType.Synergicvalidatetypeid = Synergicdirectory.Synergicvalidatetypeid " & _
                "LEFT OUTER JOIN Secretlevel ON Secretlevel.Secretlevelid = Synergicdirectory.Secretlevelid " & _
                "LEFT OUTER JOIN Synergictype ON Synergicdirectory.Synergictypeid = Synergictype.Synergictypeid " & _
                "INNER JOIN Employee ON Synergicdirectory.Submitemployeeid = Employee.Employeeid " & _
                "LEFT OUTER JOIN Factory ON Product.Factoryid =Factory.Factoryid " & _
                "LEFT OUTER JOIN  " & _
                "(SELECT Synergicdirectory.Synergicdirectoryid, COUNT(Specinfo.Specid) AS SpecCount " & _
                "FROM Synergicdirectory " & _
                "INNER JOIN SynergicDirectorySpecInfo ON SynergicDirectorySpecInfo.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & _
                "INNER JOIN Specinfo ON SynergicDirectorySpecInfo.Specinfoid = Specinfo.Specinfoid " & _
                "GROUP BY Synergicdirectory.Synergicdirectoryid " & _
                ") CSpec " & _
                "ON CSpec.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & _
                "LEFT OUTER JOIN  " & _
                "(SELECT  Synergicdirectory.Synergicdirectoryid, COUNT(Customer.Customerid) AS CustomerCount " & _
                "FROM Synergicdirectory " & _
                "INNER JOIN SynergicDirectoryCustomer ON SynergicDirectoryCustomer.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & _
                "INNER JOIN Customer ON SynergicDirectoryCustomer.Customerid = Customer.Customerid " & _
                "GROUP BY Synergicdirectory.Synergicdirectoryid " & _
                ") CCustomer " & _
                "ON CCustomer.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & _
                "WHERE Synergicdirectory.Status = 1 "

            If strProductName <> "" Then
                strSQL = strSQL & "   AND Productbase.Productname LIKE '%" & strProductName & "%' "
            End If
            If strWorkflowName <> "" Then
                strSQL = strSQL & "   AND Workflowbase.Workflowname LIKE '%" & strWorkflowName & "%' "
            End If
            If strFactoryName <> "" Then
                strSQL = strSQL & "   AND Factory.Factoryname ='" & strFactoryName & "' "
            End If
            strSQL = strSQL & "ORDER BY Factory.Factoryname,  Productbase.Productname, Synergicdirectory.Submitdate "

            Dim paraPage As New uMESPagingDataDTO
            paraPage.CurrentPageIndex = Convert.ToInt32(QueryCondition("CurrentPageIndex").ToString)
            paraPage.PageSize = Convert.ToInt32(QueryCondition("PageSize").ToString)
            paraPage.strSQL = strSQL
            Dim result As New uMESProcessResult

            oResult = dal.RunProcedureForPage(paraPage)

            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 获取已经保存的外协目录详细信息
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetSynergicDirectoryDetailInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSynergicDirectoryDetailInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, SynergicdirectoryName As String
            SynergicdirectoryName = ""
            If QueryCondition.Keys.Contains("SynergicdirectoryName") = True Then
                SynergicdirectoryName = QueryCondition("SynergicdirectoryName").ToString()
            End If

            strSQL = "SELECT Synergicdirectory.SynergicdirectoryName,Specbase.SpecName, Spec.Specrevision, Specinfo.Spectype " & vbCrLf & _
                "FROM Synergicdirectory " & vbCrLf & _
                "INNER JOIN SynergicDirectorySpecInfo ON SynergicDirectorySpecInfo.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & vbCrLf & _
                "INNER JOIN Specinfo ON SynergicDirectorySpecInfo.Specinfoid = Specinfo.Specinfoid " & vbCrLf & _
                "INNER JOIN Spec ON Spec.Specid =  Specinfo.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Specbase.Specbaseid = Spec.Specbaseid" & vbCrLf & _
                "WHERE 1=1 " & vbCrLf
            If SynergicdirectoryName <> "" Then
                strSQL = strSQL & " AND Synergicdirectory.SynergicdirectoryName = '" & SynergicdirectoryName & "' " & vbCrLf
            End If
            strSQL = strSQL & "ORDER BY Specbase.SpecName" & vbCrLf

            Dim dtSpec As DataTable = dal.GetCheckTempInfo(strSQL)

            strSQL = "SELECT Synergicdirectory.SynergicdirectoryName, Customer.CustomerName" & vbCrLf & _
                "FROM Synergicdirectory " & vbCrLf & _
                "INNER JOIN SynergicDirectoryCustomer ON SynergicDirectoryCustomer.Synergicdirectoryid = Synergicdirectory.Synergicdirectoryid " & vbCrLf & _
                "INNER JOIN Customer ON SynergicDirectoryCustomer.Customerid = Customer.Customerid" & vbCrLf &
                "WHERE 1=1 " & vbCrLf
            If SynergicdirectoryName <> "" Then
                strSQL = strSQL & " AND Synergicdirectory.SynergicdirectoryName = '" & SynergicdirectoryName & "' " & vbCrLf
            End If
            strSQL = strSQL & "ORDER BY Customer.CustomerName" & vbCrLf

            Dim dtCustomer As DataTable = dal.GetCheckTempInfo(strSQL)

            Dim ds As New DataSet
            ds.Tables.Add(dtSpec)
            ds.Tables(0).TableName = "dtSpec"
            ds.Tables.Add(dtCustomer)
            ds.Tables(1).TableName = "dtCustomer"
            oResult.DBDataSet = ds
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function


    ''' <summary>
    ''' 根据Product获取Workflow
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetWorkflowByProduct(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetWorkflowByProduct
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strProductName, strProductRev As String
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strProductRev = ""
            If QueryCondition.Keys.Contains("ProductRev") = True Then
                strProductRev = QueryCondition("ProductRev").ToString()
            End If

            strSQL = "SELECT DISTINCT Factory.FactoryName, CWorkflow.Workflowname, CWorkflow.Workflowrevision" & vbCrLf & _
                "FROM Product" & vbCrLf & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid" & vbCrLf & _
                "LEFT OUTER JOIN Factory ON Factory.Factoryid = Product.Factoryid" & vbCrLf & _
                "LEFT OUTER JOIN" & vbCrLf & _
                "(SELECT Product.Productid, Workflowbase.Workflowname, Workflow.Workflowrevision" & vbCrLf & _
                "FROM Product " & vbCrLf & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid" & vbCrLf & _
                "INNER JOIN Workflow ON Product.Workflowid = Workflow.Workflowid" & vbCrLf & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "WHERE Product.Workflowbaseid = '0000000000000000'" & vbCrLf
            If strProductName <> "" Then
                strSQL = strSQL & " AND Productbase.Productname = '" & strProductName & "' " & vbCrLf
            End If
            If strProductRev <> "" Then
                strSQL = strSQL & " AND Product.Productrevision = '" & strProductRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Productbase.Revofrcdid = Product.Productid" & vbCrLf
            End If
            strSQL = strSQL & "UNION ALL" & vbCrLf & _
                "SELECT Product.Productid, Workflowbase.Workflowname, Workflow.Workflowrevision" & vbCrLf & _
                "FROM Product " & vbCrLf & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid" & vbCrLf & _
                "INNER JOIN Workflowbase ON Product.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "INNER JOIN Workflow ON Workflowbase.Workflowbaseid = Workflow.Workflowbaseid" & vbCrLf & _
                "WHERE Product.Workflowid = '0000000000000000'" & vbCrLf

            If strProductName <> "" Then
                strSQL = strSQL & " AND Productbase.Productname = '" & strProductName & "' " & vbCrLf
            End If
            If strProductRev <> "" Then
                strSQL = strSQL & " AND Product.Productrevision = '" & strProductRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Productbase.Revofrcdid = Product.Productid" & vbCrLf
            End If
            strSQL = strSQL & ") CWorkflow" & vbCrLf & _
                "ON CWorkflow.Productid = Product.Productid WHERE 1=1" & vbCrLf

            If strProductName <> "" Then
                strSQL = strSQL & " AND Productbase.Productname = '" & strProductName & "' " & vbCrLf
            End If
            If strProductRev <> "" Then
                strSQL = strSQL & " AND Product.Productrevision = '" & strProductRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Productbase.Revofrcdid = Product.Productid" & vbCrLf
            End If
            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 获取已经保存的外协目录信息
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetHasSaveSynergicDirectoryInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetHasSaveSynergicDirectoryInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strProductName, strProductRev, strWorkflowName, strWorkflowRev As String
            strProductName = ""
            If QueryCondition.Keys.Contains("ProductName") = True Then
                strProductName = QueryCondition("ProductName").ToString()
            End If
            strProductRev = ""
            If QueryCondition.Keys.Contains("ProductRev") = True Then
                strProductRev = QueryCondition("ProductRev").ToString()
            End If
            strWorkflowName = ""
            If QueryCondition.Keys.Contains("WorkflowName") = True Then
                strWorkflowName = QueryCondition("WorkflowName").ToString()
            End If
            strWorkflowRev = ""
            If QueryCondition.Keys.Contains("WorkflowRev") = True Then
                strWorkflowRev = QueryCondition("WorkflowRev").ToString()
            End If
            strSQL = "SELECT Synergicdirectory.Synergicdirectoryname " & vbCrLf & _
                 "FROM Synergicdirectory " & _
                "INNER JOIN Product ON Synergicdirectory.Productid = Product.Productid " & _
                "INNER JOIN Productbase ON Product.Productbaseid = Productbase.Productbaseid " & _
                "INNER JOIN Workflow ON Synergicdirectory.Workflowid = Workflow.Workflowid " & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid " & _
                "WHERE 1=1 "
            If strProductName <> "" Then
                strSQL = strSQL & " AND Productbase.Productname = '" & strProductName & "' " & vbCrLf
            End If
            If strProductRev <> "" Then
                strSQL = strSQL & " AND Product.Productrevision = '" & strProductRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Productbase.Revofrcdid = Product.Productid" & vbCrLf
            End If
            If strWorkflowName <> "" Then
                strSQL = strSQL & " AND Workflowbase.Workflowname = '" & strWorkflowName & "' " & vbCrLf
            End If
            If strWorkflowRev <> "" Then
                strSQL = strSQL & " AND Workflow.Workflowrevision = '" & strWorkflowRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Workflowbase.Revofrcdid = Workflow.Workflowid" & vbCrLf
            End If
            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 获取外协厂家信息
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetCustomerInfo(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetCustomerInfo
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL As String

            strSQL = "SELECT Customer.Customername, Customer.Description " & vbCrLf & _
                "FROM Customer WHERE 1=1 ORDER BY Customer.Customername" & vbCrLf

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)

            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function


    ''' <summary>
    ''' 根据Workflow获取Spec
    ''' </summary>
    ''' <returns></returns>
    ''' 
    Private Function GetSpecInfoByWorkflow(ByVal QueryCondition As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetSpecInfoByWorkflow
        Dim oResult As New uMESProcessResult

        Try
            Dim strSQL, strWorkflowName, strWorkflowRev As String
            strWorkflowName = ""
            If QueryCondition.Keys.Contains("WorkflowName") = True Then
                strWorkflowName = QueryCondition("WorkflowName").ToString()
            End If
            strWorkflowRev = ""
            If QueryCondition.Keys.Contains("WorkflowRev") = True Then
                strWorkflowRev = QueryCondition("WorkflowRev").ToString()
            End If

            strSQL = "SELECT CSpec.Specname, CSpec.Specrevision, CSpec.SynergicType, CSpec.Sequence, CSpec.Iscooperation" & vbCrLf & _
                "FROM Workflow " & vbCrLf & _
                "INNER JOIN Workflowbase ON Workflow.Workflowbaseid = Workflowbase.Workflowbaseid" & vbCrLf & _
                "INNER JOIN" & vbCrLf & _
                "(" & vbCrLf & _
                "SELECT Workflowstep.Workflowid, Specbase.Specname, Spec.Specrevision, Workflowstep.Sequence," & vbCrLf & _
                "       DECODE(Spec.Iscooperation,'0', '厂外外协','1', '厂内外协'） AS SynergicType, Spec.Iscooperation " & vbCrLf & _
                "FROM Workflowstep " & vbCrLf & _
                "INNER JOIN Spec ON Workflowstep.Specid = Spec.Specid" & vbCrLf & _
                "INNER JOIN Specbase ON Spec.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "WHERE Workflowstep.Specbaseid = '0000000000000000'" & vbCrLf & _
                "UNION ALL" & vbCrLf & _
                "SELECT Workflowstep.Workflowid, Specbase.Specname, Spec.Specrevision, Workflowstep.Sequence," & vbCrLf & _
                "       DECODE(Spec.Iscooperation,'0', '厂外外协','1', '厂内外协') AS SynergicType, Spec.Iscooperation" & vbCrLf & _
                "FROM Workflowstep " & vbCrLf & _
                "INNER JOIN Specbase ON Workflowstep.Specbaseid = Specbase.Specbaseid" & vbCrLf & _
                "INNER JOIN Spec ON Specbase.Revofrcdid = Spec.Specid" & vbCrLf & _
                "WHERE Workflowstep.Specid = '0000000000000000'" & vbCrLf & _
                ") CSpec" & vbCrLf & _
                "ON CSpec.Workflowid = Workflow.Workflowid WHERE 1=1" & vbCrLf

            If strWorkflowName <> "" Then
                strSQL = strSQL & " AND Workflowbase.Workflowname = '" & strWorkflowName & "' " & vbCrLf
            End If
            If strWorkflowRev <> "" Then
                strSQL = strSQL & " AND Workflow.Workflowrevision = '" & strWorkflowRev & "'" & vbCrLf
            Else
                strSQL = strSQL & " AND Workflowbase.Revofrcdid = Workflow.Workflowid" & vbCrLf
            End If
            strSQL = strSQL & "ORDER BY CSpec.Sequence"

            Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
            dtMain = DataAdjust.FormatDataSetSpecNameByColumName("SpecName", dtMain)
            oResult.DBTable = dtMain
            oResult.Result = True
            Return oResult
        Catch ex As Exception
            oResult.Result = False
            oResult.Message = ex.Message
            Return oResult
        End Try
    End Function

    ''' <summary>
    ''' 创建外协目录信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">创建外协目录所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function CreateSynergicDirectory(ByVal oSynergicInfoDTO As uMESSynergicDirectoryDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.CreateSynergicDirectory
        CreateSynergicDirectory = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName, strSubentityListName2 As String
            strTxnDocName = "SynergicDirectoryMaintDoc"
            strTxnName = "SynergicDirectoryMaint"
            strEventName = "New"
            strSubentityListName = "SpecInfo"
            strSubentityListName2 = "Customer"

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Name"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicDirectoryName
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strProductName As String = oSynergicInfoDTO.ProductName
            Dim strProductRev As String = oSynergicInfoDTO.ProductRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Product"
            dataEntity.ClientDataValue = strProductName
            If strProductRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strProductRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strProductRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
            Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Workflow"
            dataEntity.ClientDataValue = strWorkflowName
            If strWorkflowRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strWorkflowRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strWorkflowRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Qty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Qty
            m_DataList.Add(dataEntity)

            If oSynergicInfoDTO.FactoryName <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Factory"
                dataEntity.ClientDataValue = oSynergicInfoDTO.FactoryName
                m_DataList.Add(dataEntity)
            End If

            If oSynergicInfoDTO.SynergicValidateType <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SynergicValidateType"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicValidateType
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "IsFirstSynergic"
            dataEntity.ClientDataValue = oSynergicInfoDTO.IsFirstSynergic
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "IsImport"
            dataEntity.ClientDataValue = oSynergicInfoDTO.IsImport
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Status"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Status
            m_DataList.Add(dataEntity)

            If oSynergicInfoDTO.SecretLevel <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SecretLevel"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SecretLevel
                m_DataList.Add(dataEntity)
            End If

            If oSynergicInfoDTO.SynergicType <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SynergicType"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicType
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtSpecList As DataTable = oSynergicInfoDTO.SpecInfo

            If dtSpecList IsNot Nothing Then
                If dtSpecList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtSpecList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtSpecList.Rows(i).Item("SpecName").ToString
                        Dim strSpecDetailRev As String = dtSpecList.Rows(i).Item("SpecRev").ToString
                        If strSpecDetailRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecType"
                        stepEntity.ClientDataValue = dtSpecList.Rows(i).Item("SpecType").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim m_CustomerList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtCustomerList As DataTable = oSynergicInfoDTO.Customer

            If dtCustomerList IsNot Nothing Then
                If dtCustomerList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtCustomerList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        If dtCustomerList.Rows(i).Item("CustomerName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Name"
                            stepEntity.ClientDataValue = dtCustomerList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                            m_CustomerList.Add(i.ToString, m_Child)
                        End If


                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.CreateModelHasTwoSubentityList(strTxnDocName, strTxnName, strEventName, m_DataList, strSubentityListName, m_ChildList, strSubentityListName2, m_CustomerList, strInfo)

            If success = True Then
                CreateSynergicDirectory = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 创建外协目录信息
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">创建外协目录所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function UpdateSynergicDirectory(ByVal oSynergicInfoDTO As uMESSynergicDirectoryDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.UpdateSynergicDirectory
        UpdateSynergicDirectory = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName, strSubentityListName, strSubentityListName2 As String
            strTxnDocName = "SynergicDirectoryMaintDoc"
            strTxnName = "SynergicDirectoryMaint"
            strEventName = "Load"
            strSubentityListName = "SpecInfo"
            strSubentityListName2 = "Customer"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicDirectoryName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim intSpecCount, intCustomerCount As Integer
            intSpecCount = oSynergicInfoDTO.SpecCount
            intCustomerCount = oSynergicInfoDTO.CustomerCount

            Dim m_DataList As New List(Of ClientAPIEntity)

            Dim dataEntity As New ClientAPIEntity

            dataEntity = New ClientAPIEntity
            Dim strProductName As String = oSynergicInfoDTO.ProductName
            Dim strProductRev As String = oSynergicInfoDTO.ProductRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Product"
            dataEntity.ClientDataValue = strProductName
            If strProductRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strProductRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strProductRev
            End If
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            Dim strWorkflowName As String = oSynergicInfoDTO.WorkflowName
            Dim strWorkflowRev As String = oSynergicInfoDTO.WorkflowRev

            dataEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Workflow"
            dataEntity.ClientDataValue = strWorkflowName
            If strWorkflowRev <> "" Then
                dataEntity.ClientDataIsROR = False
                dataEntity.ClientDataVersion = strWorkflowRev
            Else
                dataEntity.ClientDataIsROR = True
                dataEntity.ClientDataVersion = strWorkflowRev
            End If
            m_DataList.Add(dataEntity)


            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "Qty"
            dataEntity.ClientDataValue = oSynergicInfoDTO.Qty
            m_DataList.Add(dataEntity)

            If oSynergicInfoDTO.FactoryName <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "Factory"
                dataEntity.ClientDataValue = oSynergicInfoDTO.FactoryName
                m_DataList.Add(dataEntity)
            End If

            If oSynergicInfoDTO.SynergicValidateType <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SynergicValidateType"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicValidateType
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "IsFirstSynergic"
            dataEntity.ClientDataValue = oSynergicInfoDTO.IsFirstSynergic
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "IsImport"
            dataEntity.ClientDataValue = oSynergicInfoDTO.IsImport
            m_DataList.Add(dataEntity)

            If oSynergicInfoDTO.SecretLevel <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SecretLevel"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SecretLevel
                m_DataList.Add(dataEntity)
            End If

            If oSynergicInfoDTO.SynergicType <> "" Then
                dataEntity = New ClientAPIEntity
                dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
                dataEntity.ClientDataName = "SynergicType"
                dataEntity.ClientDataValue = oSynergicInfoDTO.SynergicType
                m_DataList.Add(dataEntity)
            End If

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitEmployee"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitEmployee
            m_DataList.Add(dataEntity)

            dataEntity = New ClientAPIEntity
            dataEntity.ClientDataTypeEnum = DataTypeEnum.DataField
            dataEntity.ClientInputTypeEnum = InputTypeEnum.Details
            dataEntity.ClientDataName = "SubmitDate"
            dataEntity.ClientDataValue = oSynergicInfoDTO.SubmitDate
            m_DataList.Add(dataEntity)

            Dim m_ChildList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtSpecList As DataTable = oSynergicInfoDTO.SpecInfo

            If dtSpecList IsNot Nothing Then
                If dtSpecList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtSpecList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        stepEntity.ClientDataTypeEnum = DataTypeEnum.RevisionedObjectField
                        stepEntity.ClientDataName = "Spec"
                        stepEntity.ClientDataValue = dtSpecList.Rows(i).Item("SpecName").ToString
                        Dim strSpecDetailRev As String = dtSpecList.Rows(i).Item("SpecRev").ToString
                        If strSpecDetailRev <> "" Then
                            stepEntity.ClientDataIsROR = False
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        Else
                            stepEntity.ClientDataIsROR = True
                            stepEntity.ClientDataVersion = strSpecDetailRev
                        End If
                        m_Child.Add(stepEntity)

                        stepEntity = New ClientAPIEntity
                        stepEntity.ClientDataTypeEnum = DataTypeEnum.DataField
                        stepEntity.ClientDataName = "SpecType"
                        stepEntity.ClientDataValue = dtSpecList.Rows(i).Item("SpecType").ToString
                        m_Child.Add(stepEntity)

                        m_ChildList.Add(i.ToString, m_Child)
                    Next
                End If
            End If

            Dim m_CustomerList As New Dictionary(Of String, List(Of ClientAPIEntity))

            Dim dtCustomerList As DataTable = oSynergicInfoDTO.Customer

            If dtCustomerList IsNot Nothing Then
                If dtCustomerList.Rows.Count > 0 Then
                    For i As Integer = 0 To dtCustomerList.Rows.Count - 1
                        Dim m_Child As New List(Of ClientAPIEntity)
                        Dim stepEntity As New ClientAPIEntity

                        If dtCustomerList.Rows(i).Item("CustomerName").ToString <> "" Then
                            stepEntity = New ClientAPIEntity
                            stepEntity.ClientDataTypeEnum = DataTypeEnum.NamedObjectField
                            stepEntity.ClientDataName = "Name"
                            stepEntity.ClientDataValue = dtCustomerList.Rows(i).Item("CustomerName").ToString
                            m_Child.Add(stepEntity)
                            m_CustomerList.Add(i.ToString, m_Child)
                        End If


                    Next
                End If
            End If

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.UpdateModelHasTwoSubentityList(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                                strUpdateCDOType, m_DataList, strSubentityListName, m_ChildList, _
                                                                intSpecCount, strSubentityListName2, m_CustomerList, intCustomerCount, strInfo)

            If success = True Then
                UpdateSynergicDirectory = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 删除外协目录
    ''' </summary>
    ''' <param name="oSynergicInfoDTO">删除外协目录所需的基础信息</param>
    ''' <param name="result">执行结果</param>
    ''' <param name="message">返回结果信息</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DeleteSynergicDirectory(ByVal oSynergicInfoDTO As uMESSynergicDirectoryDTO, ByRef result As Boolean, ByRef message As String) As Boolean Implements uMESSynergicIBusinessTest.DeleteSynergicDirectory
        DeleteSynergicDirectory = False
        result = False
        Try
            Dim strInfo As String = ""
            Dim success As Boolean = False
            Dim daServerHost As ServerHostInfo = oSynergicInfoDTO.ServerHostInfo

            Dim strTxnDocName, strTxnName, strEventName As String
            strTxnDocName = "SynergicDirectoryMaintDoc"
            strTxnName = "SynergicDirectoryMaint"
            strEventName = "Delete"

            Dim strUpdateName, strUpdateVersion, strUpdateCDOType As String
            strUpdateName = oSynergicInfoDTO.SynergicDirectoryName
            strUpdateVersion = ""
            strUpdateCDOType = "NDO"

            Dim serverUser As String = daServerHost.UserName
            Dim serverPassword As String = daServerHost.Password

            Dim clientData As New CamstarClientAPI(serverUser, serverPassword)
            success = clientData.DeleteModel(strTxnDocName, strTxnName, strUpdateName, strUpdateVersion, _
                                                            strUpdateCDOType, strInfo)

            If success = True Then
                DeleteSynergicDirectory = True
                result = True
            End If

            message = strInfo

        Catch ex As Exception
            result = False
            message = ex.Message
            Return False
        End Try
    End Function

    Function UpdateSynergicspecvalidate(ByVal para As uMESSynergicInfoDTO) As uMESProcessResult Implements uMESSynergicIBusinessTest.UpdateSynergicSpecValidate
        Dim strList As New ArrayList
        Dim strSQL As String = String.Format("update synergicspecvalidate set Status=0 where Synergicspecvalidatename='{0}'", para.SynergicSpecValidateName)
        strList.Add(strSQL)
        UpdateSynergicspecvalidate = dal.SaveDataInfo(strList)
    End Function

#Region "得到在制批次和对应的外协申请单信息"
    Public Function GetWipContainerAndValidate(ByVal para As Dictionary(Of String, String)) As uMESProcessResult Implements uMESSynergicIBusinessTest.GetWipContainerAndValidate
        Dim strTogetherFlag As String = ""
        Dim dispBusess As uMESDispatchBusiness = New uMESDispatchBusiness()
        Dim commBusiness As uMESCommonBusiness = New uMESCommonBusiness()
        Dim strContainerName As String = ""
        Dim strProductName As String = ""
        Dim strSpecID As String = ""

        If para.Keys.Contains("ContainerName") = True Then
            strContainerName = commBusiness.ReplaceContainerName(para("ContainerName").ToString)
            Dim rTmp As uMESProcessResult = dispBusess.GetContainerInfo(strContainerName)
            If rTmp.Result = True Then
                Try
                    strTogetherFlag = rTmp.DBTable.Rows(0)("TogetherFlag").ToString
                    strProductName = rTmp.DBTable.Rows(0)("productName").ToString
                    strSpecID = rTmp.DBTable.Rows(0)("specID").ToString
                Catch ex As Exception
                    strTogetherFlag = ""
                End Try
            End If
        End If

        'Dim strQuery As String = "select * from conDispatch t where 1=1 "

        Dim strQuery As String = "SELECT wb.workflowname, t.* FROM conDispatch t " & vbCrLf
        strQuery += " LEFT JOIN workflow  w ON w.workflowid=t.workflowid " & vbCrLf
        strQuery += " LEFT JOIN Workflowbase wb ON wb.workflowbaseid=w.workflowbaseid where 1=1 "

        If para.Keys.Contains("FactoryName") = True Then
            strQuery += " AND t.factoryname = '" & para("FactoryName").ToString & "'" & vbCrLf
        End If

        If para.Keys.Contains("WorkCenterName") = True Then
            strQuery += "AND t.workcentername = '" & para("WorkCenterName").ToString & "'" & vbCrLf
        End If

        If para.Keys.Contains("ContainerName") = True Then
            If strTogetherFlag = "" Then
                If para("ContainerName").ToString.Trim() <> "" Then
                    strQuery += "AND LOWER(t.containername) = '" & strContainerName.ToLower & "'" & vbCrLf
                End If
            Else
                strQuery += "AND LOWER(t.togetherflag) = '" & strTogetherFlag.ToLower & "'" & vbCrLf
                strQuery += " AND LOWER(t.productname) = '" & strProductName.ToLower() & "' " & vbCrLf
                strQuery += " AND (t.specid='" & strSpecID & "' OR t.revofrcdid='" & strSpecID & "')" & vbCrLf
            End If
        End If

        If para.Keys.Contains("SearchContainerName") = True Then
            If para("SearchContainerName").ToString.Trim() <> "" Then
                strQuery += "AND LOWER(t.containername) LIKE '%" & para("SearchContainerName").ToString.ToLower & "%'" & vbCrLf
            End If
        End If
        If para.Keys.Contains("ProductName") = True Then
            strQuery += "AND LOWER(t.productname) LIKE '%" & para("ProductName").ToString.ToLower & "%'" & vbCrLf
        End If


        If para.Keys.Contains("specname") = True Then
            strQuery += "AND LOWER(t.workflowstepname) LIKE '%" & para("specname").ToString.ToLower & "%'" & vbCrLf
        End If

        strQuery += " ORDER BY  t.containername"

        Dim paraPage As New uMESPagingDataDTO
        paraPage.CurrentPageIndex = Convert.ToInt32(para("CurrentPageIndex").ToString)
        paraPage.PageSize = Convert.ToInt32(para("PageSize").ToString)
        paraPage.strSQL = strQuery

        Dim r As uMESProcessResult = dal.RunProcedureForPage(paraPage)
        Dim strContainerIDList As String = ""
        For Each row As DataRow In r.DBTable.Rows
            strContainerIDList = strContainerIDList + "'" + row("containerid").ToString().Trim() + "'" + ","
        Next
        If strContainerIDList.Trim().Length > 0 Then
            strContainerIDList = strContainerIDList.Substring(0, strContainerIDList.Length - 1)
        Else
            strContainerIDList = "' '"
        End If

        strQuery = "SELECT ssv1.Synergicspecvalidateid,ssv1.containerid,ssv1.synergicspecvalidatename,ssv1.auditingdate,ssv1.submitdate," & vbCrLf
        strQuery += "e.fullname as submitName,e1.fullname as auitingName,ssv1.auditingdispose,ssv1.status FROM SynergicSpecValidate ssv1 " & vbCrLf
        strQuery += "LEFT JOIN employee e on e.employeeid=ssv1.submitemployeeid " & vbCrLf
        strQuery += " LEFT JOIN employee e1 on e1.employeeid=ssv1.auditingemployeeid " & vbCrLf
        strQuery += " WHERE  ssv1.containerid IN ( " + strContainerIDList + ")"

        Dim detailTable As DataTable = dal.GetSpecDispatchInfo(strQuery)

        Dim mainTmpTable As DataTable = r.DBTable.Clone()

        For Each row As DataRow In r.DBTable.Rows
            Dim strFilter As String = String.Format("containerid='{0}'", row("containerid").ToString().Trim())
            Dim rows As DataRow() = mainTmpTable.Select(strFilter)
            If rows.Length = 0 Then
                mainTmpTable.ImportRow(row)
            End If
        Next

        Dim ds As New DataSet
        ds.Tables.Add(mainTmpTable.Copy())
        ds.Tables(0).TableName = "dtMain"
        ds.Tables.Add(detailTable.Copy())
        ds.Tables(1).TableName = "dtDetail"

        Dim parentColunms = New DataColumn(0) {ds.Tables(0).Columns("containerid")}
        Dim childColunms = New DataColumn(0) {ds.Tables(1).Columns("containerid")}
        ds.Relations.Add("rs0", parentColunms, childColunms)

        Dim result As New uMESProcessResult
        result.Result = True
        result.DBDataSet = ds.Copy()
        result.RowCount = r.RowCount
        Return result
    End Function
#End Region

    Protected Function GetFactoryInfo(ByVal strFatoryName As String) As DataTable Implements uMESSynergicIBusinessTest.GetFactoryInfo
        Dim strSql As String = String.Format("SELECT t.factoryid FROM factory t WHERE t.factoryname='" & strFatoryName & "'")
        Dim facotyTable As DataTable = dal.GetSpecDispatchInfo(strSql)
        Return facotyTable
    End Function

    Protected Function GetCustomInfo(ByVal strCustomName As String) As DataTable Implements uMESSynergicIBusinessTest.GetCustomInfo
        Dim strSql As String = String.Format("SELECT * FROM customer t WHERE t.customername='" & strCustomName & "'")
        Dim customTable As DataTable = dal.GetSpecDispatchInfo(strSql)
        Return customTable
    End Function

    '判断转工单是否处理
    Public Function IsDealSynergicInfo(ByVal SynergicInfoName As String) As Boolean Implements uMESSynergicIBusinessTest.IsDealSynergicInfo
        Dim strSQL As String
        strSQL = "select SynergicInfoName from synergicinfo WHERE status='0' and SynergicInfoName='" & SynergicInfoName & "'"
        Dim dtMain As DataTable = dal.GetCheckTempInfo(strSQL)
        IsDealSynergicInfo = False
        If dtMain Is Nothing Then
            IsDealSynergicInfo = False
        End If
        If dtMain.Rows.Count > 0 Then
            IsDealSynergicInfo = True
        End If
    End Function

End Class

